mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-26 18:59:17 +08:00
Oracle distinct use rowumber
This commit is contained in:
@@ -21,6 +21,32 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string ToSqlString()
|
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 oldOrderBy = this.OrderByValue;
|
||||||
string externalOrderBy = oldOrderBy;
|
string externalOrderBy = oldOrderBy;
|
||||||
|
|||||||
Reference in New Issue
Block a user