Skip to content

Commit 0efbc0e

Browse files
committed
Update core
1 parent 31e4a63 commit 0efbc0e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleQueryBuilder.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,32 @@ public override string SqlTemplate
2121
}
2222
}
2323
public override string ToSqlString()
24+
{
25+
var oldTake = Take;
26+
var oldSkip = Skip;
27+
var isDistinctPage = IsDistinct && (Take > 1 || Skip > 1);
28+
if (isDistinctPage)
29+
{
30+
Take = null;
31+
Skip = null;
32+
}
33+
var result = _ToSqlString();
34+
if (isDistinctPage)
35+
{
36+
if (this.OrderByValue.HasValue())
37+
{
38+
Take = int.MaxValue;
39+
result = result.Replace("DISTINCT", $" DISTINCT TOP {int.MaxValue} ");
40+
}
41+
Take = oldTake;
42+
Skip = oldSkip;
43+
result = this.Context.SqlQueryable<object>(result).Skip(Skip??0).Take(Take??0).ToSql().Key;
44+
45+
46+
}
47+
return result;
48+
}
49+
public string _ToSqlString()
2450
{
2551
string oldOrderBy = this.OrderByValue;
2652
string externalOrderBy = oldOrderBy;

Src/Asp.NetCore2/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerQueryBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override string ToSqlString()
3535
}
3636
Take = oldTake;
3737
Skip = oldSkip;
38-
result =this.Context.SqlQueryable<object>(result).Skip(Skip.Value).Take(Take.Value).ToSql().Key;
38+
result =this.Context.SqlQueryable<object>(result).Skip(Skip??0).Take(Take??0).ToSql().Key;
3939

4040

4141
}

0 commit comments

Comments
 (0)