mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Sqlerver support distinct use rownumber page
This commit is contained in:
parent
a6b3c965de
commit
3ab92f8a02
@ -15,8 +15,33 @@ namespace SqlSugar
|
||||
return "SELECT {0}{"+UtilConstants.ReplaceKey+"} FROM {1}{2}{3}{4}";
|
||||
}
|
||||
}
|
||||
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.Value).Take(Take.Value).ToSql().Key;
|
||||
|
||||
|
||||
public override string ToSqlString()
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public string _ToSqlString()
|
||||
{
|
||||
string oldOrderBy = this.OrderByValue;
|
||||
string externalOrderBy = oldOrderBy;
|
||||
|
Loading…
Reference in New Issue
Block a user