注意:Aop一定要设置在你操作语句之前,不然不会生效,还有必须是同一个SqlSuagrClient才会有效
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
public async Task<dynamic> GetNoPagingList([FromQuery] YkzptSafecompanypromiseListQueryInput input) { //每次Sql执行前事件 _db.Aop.OnLogExecuting = (sql, data) => { var n1 = sql; }; var data = await _db.Queryable<YkzptSafecompanypromiseEntity>() .WhereIF(!string.IsNullOrEmpty(input.warehouseId), p => p.WarehouseId.Equals(input.warehouseId)) .Select(it => new YkzptSafecompanypromiseListOutput { id = it.Id, warehouseId = it.WarehouseId, promiseDate = it.PromiseDate, mainPerson = it.MainPerson, promiseContent = it.PromiseContent, companyStateInfor = it.CompanyStateInfor, }).MergeTable().OrderBy(sidx + " " + input.sort).ToListAsync(); return data; } |
全局
1 2 3 4 5 6 7 8 9 10 11 12 |
public DbContext() { Db = Instance; //调式代码 用来打印SQL Db.Aop.OnLogExecuting = (sql, pars) => { string s = sql; Console.WriteLine(sql + "\r\n" + Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); Console.WriteLine(); }; } |
from:https://www.cnblogs.com/canfengfeixue/p/15649378.html