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
https://www.donet5.com/Home/Doc
MIT License
5.27k stars 1.33k forks source link

The sqlsugar query paging data does not match the database #1097

Closed soefly closed 1 year ago

soefly commented 1 year ago

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

soefly commented 1 year ago

1667955348015

soefly commented 1 year ago

1667956700283

DotNetNext commented 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)); 
                   }

           });
DotNetNext commented 1 year ago

If there is a where condition, the count may not be the same as the database

soefly commented 1 year ago

Thank you.