Update core

This commit is contained in:
sunkaixuan 2022-03-30 21:45:28 +08:00
parent 31e4a63669
commit 0efbc0e5d8
2 changed files with 27 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}