[转]sqlsugar打印输出sql语句

原文出处: http://cnblogs.com/luckyting/articles/11038694.html 

主要是, 在sqlsugar的帮助类的构造函数里加上:

            _db.Aop.OnLogExecuting = (sql, pars) =>
            {
                var s1 = sql;//断点打在这里看内部生成的sql语句...
            };

 完整的例子:

    public class BaseDal where T : class, new()
    {
        public BaseDal(DbContext context)
        {
            _context = context;
            _db = context.Db;
            _entityDB = context.GetEntityDB(_db);

            _db.Aop.OnLogExecuting = (sql, pars) =>
            {
                var s1 = sql;//断点打这里看sql语句...
            };
        }
    }

你可能感兴趣的:(sqlsugar)