当前位置:Gxlcms > 数据库问题 > Ibatis 测试出SQL

Ibatis 测试出SQL

时间:2021-07-01 10:21:17 帮助过:2人阅读

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

标签:

人气教程排行