Oracle distinct use rowumber

This commit is contained in:
sunkaixuan
2022-03-30 21:41:32 +08:00
parent 92de590777
commit 089288bb1a

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;