From c2750b8099cf6558f700c47ec3c447981137bb9a Mon Sep 17 00:00:00 2001 From: "guoshun.du" Date: Tue, 9 Sep 2025 19:56:33 +0800 Subject: [PATCH] =?UTF-8?q?GetLimit=E7=9A=84=E6=8A=A5=E7=A9=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SqlBuilder/OceanBaseForOracleExpressionContext.cs | 2 +- .../SqlBuilder/TDSQLForPGODBCExpressionContext.cs | 2 +- .../ExpressionsToSql/Subquery/Items/SubTake.cs | 10 ++++------ .../SqlSugar/ExpressionsToSql/Subquery/Items/SubTop.cs | 5 +++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs index 31c8bc592..b5c97829f 100644 --- a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs +++ b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs @@ -76,7 +76,7 @@ namespace SqlSugar.OceanBaseForOracle public override string GetLimit() { int num = 1; - if (this.Case?.Num != 1) + if (this.Case?.Num > 1) { num = this.Case.Num; } diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs index 05cb81a82..1c7720eb2 100644 --- a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs +++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs @@ -134,7 +134,7 @@ namespace SqlSugar.TDSQLForPGODBC public override string GetLimit() { int num = 1; - if (this.Case.Num != 1) + if (this.Case?.Num > 1) { num = this.Case.Num; } diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTake.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTake.cs index 534fa0a5d..1bb530640 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTake.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTake.cs @@ -82,14 +82,12 @@ namespace SqlSugar } else if (this.Context.GetLimit() != null) { - if (this?.Context?.Case?.HasWhere == true) + if (this.Context.Case == null) { - this.Context.Case.HasWhere = this.HasWhere; - } - if (this?.Context?.Case?.Num != 1) - { - this.Context.Case.Num = num; + this.Context.Case = new ExpressionContextCase(); } + this.Context.Case.HasWhere = this.HasWhere; + this.Context.Case.Num = num; return this.Context.GetLimit(); } else diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTop.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTop.cs index 312ed677b..36a7da379 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTop.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubTop.cs @@ -67,10 +67,11 @@ namespace SqlSugar } else if (this.Context.GetLimit()!=null) { - if (this?.Context?.Case?.HasWhere == true) + if (this.Context.Case == null) { - this.Context.Case.HasWhere = this.HasWhere; + this.Context.Case = new ExpressionContextCase(); } + this.Context.Case.HasWhere = this.HasWhere; return this.Context.GetLimit(); } else -- Gitee