Ibatis 测试出SQL
Posted 笨小孩做开发
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ibatis 测试出SQL相关的知识,希望对你有一定的参考价值。
String sql = Brg.Global.Map.BaseBatis.GetRuntimeSql("select_T_JewelleryProductType", _Model);
/// <summary>
/// 得到运行时ibatis.net动态生成的SQL
/// </summary>
/// <param name="sqlMapper"></param>
/// <param name="statementName"></param>
/// <param name="paramObject"></param>
/// <returns></returns>
public static string GetRuntimeSql(string statementName, object paramObject)
{
string result = string.Empty;
try
{
IMappedStatement statement = SqlMap.GetMappedStatement(statementName);
if (!SqlMap.IsSessionStarted)
{
SqlMap.OpenConnection();
}
RequestScope scope = statement.Statement.Sql.GetRequestScope(statement, paramObject, SqlMap.LocalSession);
result = scope.PreparedStatement.PreparedSql;
}
catch (Exception ex)
{
result = "获取SQL语句出现异常:" + ex.Message;
}
return result;
}
以上是关于Ibatis 测试出SQL的主要内容,如果未能解决你的问题,请参考以下文章