Closed soefly closed 1 year ago
print sql Let's see
SqlSugarClient Db= new SqlSugarClient(new ConnectionConfig(){
ConnectionString = "server=xxx",
DbType = DbType.MySql,
IsAutoCloseConnection = true},
db=>{
db.Aop.OnLogExecuting = (sql, pars) =>
{
//debug
Console.WriteLine(UtilMethods.GetSqlString(DbType.MySql,sql,pars));
}
});
If there is a where condition, the count may not be the same as the database
Thank you.
var predicate = Expressionable.Create();
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NcmXid), it => it.NcmXid.Contains(parm.NcmXid));
predicate = predicate.AndIF(parm.BeginLogTime == null, it => it.LogTime >= DateTime.Now.AddDays(-1));
predicate = predicate.AndIF(parm.BeginLogTime != null, it => it.LogTime >= parm.BeginLogTime && it.LogTime <= parm.EndLogTime);
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NcmState), it => it.NcmState == parm.NcmState);
var response = _MdcCncLogRepository
.Queryable()
.OrderBy("Log_Id desc")
.Where(predicate.ToExpression())
.ToPage(parm);