1 、需引入如下4个namespace:
using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;
using IBatisNet.DataMapper.MappedStatements;
using IBatisNet.DataMapper.Scope;
2、将下面语句添加到代码去,result 即为获取的SQL
ISqlMapper sqlMapper = new DomSqlMapBuilder().Configure(); IMappedStatement statement = sqlMapper.GetMappedStatement("getlist"); ISqlMapSession session = new SqlMapSession(sqlMapper); if (sqlMapper.LocalSession != null) { session = sqlMapper.LocalSession; } else { session = sqlMapper.OpenConnection(); } RequestScope scope = statement.Statement.Sql.GetRequestScope(statement, ht, session); string resultSQL = scope.PreparedStatement.PreparedSql;
-------------------------
以上参考: http://www.cnblogs.com/buguge/archive/2011/12/20/2294608.html
3、ibatis获取正在执行的sql 限定条件
a、不可用## 来获取字符串,只能用 $$
b、必须传入对象Hashtable key value关系 然后直接
c、若Hashtable 里面有 字符串需要传入,则添加数据格式如下
ht.add("value"," '2121214-sadf-fds' ");
xml里语句 select * from dual where id=$value$
原先可直接传入 parameterClass="string"
select * from dual where id=#value#
这样会造成结果集为
select * from dual where id=:param0