DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping

Home Page:https://www.donet5.com/Home/Doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The sqlsugar query paging data does not match the database

soefly opened this issue · comments

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);

1667954786795

1667954841151

1667954896939

1667954918304

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.