mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 10:10:16 +08:00
Update core
This commit is contained in:
parent
31e4a63669
commit
0efbc0e5d8
@ -21,6 +21,32 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
public override string ToSqlString()
|
||||
{
|
||||
var oldTake = Take;
|
||||
var oldSkip = Skip;
|
||||
var isDistinctPage = IsDistinct && (Take > 1 || Skip > 1);
|
||||
if (isDistinctPage)
|
||||
{
|
||||
Take = null;
|
||||
Skip = null;
|
||||
}
|
||||
var result = _ToSqlString();
|
||||
if (isDistinctPage)
|
||||
{
|
||||
if (this.OrderByValue.HasValue())
|
||||
{
|
||||
Take = int.MaxValue;
|
||||
result = result.Replace("DISTINCT", $" DISTINCT TOP {int.MaxValue} ");
|
||||
}
|
||||
Take = oldTake;
|
||||
Skip = oldSkip;
|
||||
result = this.Context.SqlQueryable<object>(result).Skip(Skip??0).Take(Take??0).ToSql().Key;
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public string _ToSqlString()
|
||||
{
|
||||
string oldOrderBy = this.OrderByValue;
|
||||
string externalOrderBy = oldOrderBy;
|
||||
|
@ -35,7 +35,7 @@ namespace SqlSugar
|
||||
}
|
||||
Take = oldTake;
|
||||
Skip = oldSkip;
|
||||
result =this.Context.SqlQueryable<object>(result).Skip(Skip.Value).Take(Take.Value).ToSql().Key;
|
||||
result =this.Context.SqlQueryable<object>(result).Skip(Skip??0).Take(Take??0).ToSql().Key;
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user