diff --git a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs index 31c8bc592a0c118d69155e4011db5f988de07022..b5c97829f5b3395143d4661380c23991faf837ab 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 05cb81a82b1881f2fdabf9fbe6619142b01c71be..1c7720eb22b426ffe78b416ea49f00973a332e44 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 534fa0a5df7b8fc591ac0da5acd681ab140df054..1bb530640668cf31a497e9d4a520a0ad3b27b083 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 312ed677be2d3bcca758575710b7ee99db66c7ba..36a7da37959d0992209c9144a2174884d1965727 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