Ibatis根据id获取拼接好的sql语句案例

//得到sql语句;
public virtual string GetSqlStatement(string statementName, object paramObject)
{
ISqlMapper ISQLMapper = MapperFactory.Get();

IMappedStatement IMstatement = ISQLMapper.GetMappedStatement(statementName);
if (!ISQLMapper.IsSessionStarted)
{
ISQLMapper.OpenConnection();
}

RequestScope RSscope = IMstatement.Statement.Sql.GetRequestScope(IMstatement, paramObject, ISQLMapper.LocalSession);

return RSscope.PreparedStatement.PreparedSql;
}

posted @ 2014-03-24 11:29  aiaito  阅读(255)  评论(0编辑  收藏  举报