<script type="text/javascript" src="http://www.cchensoft.com/gad/blog_csdn_article.js"></script>
有时我们需要查看ibatisnet中statement生成的实际sql语句,
可以通过下面的方式取得:
public static string GetSql(string statementName, object paramObject)
{
ISqlMapper mapper = Mapper.Instance();
IMappedStatement statement = mapper.GetMappedStatement(statementName);
if (!mapper.IsSessionStarted)
{
mapper.OpenConnection();
}
RequestScope scope = statement.Statement.Sql.GetRequestScope(statement, paramObject, mapper.LocalSession);
return scope.PreparedStatement.PreparedSql;
}
<script type="text/javascript" src="http://www.cchensoft.com/gad/blog_csdn_article.js"></script>