Update 达梦

This commit is contained in:
sunkaixuan
2023-10-18 13:14:54 +08:00
parent 4968700623
commit 1b8ee8d973

View File

@@ -19,6 +19,12 @@ namespace SqlSugar
} }
public override string ToSqlString() public override string ToSqlString()
{ {
var isDistinctPage = IsDistinct && (Take > 1 || Skip > 1);
if (isDistinctPage)
{
return OffsetPage();
}
string oldOrderBy = this.OrderByValue; string oldOrderBy = this.OrderByValue;
string externalOrderBy = oldOrderBy; string externalOrderBy = oldOrderBy;
var isIgnoreOrderBy = this.IsCount && this.PartitionByValue.IsNullOrEmpty(); var isIgnoreOrderBy = this.IsCount && this.PartitionByValue.IsNullOrEmpty();
@@ -55,6 +61,16 @@ namespace SqlSugar
} }
return result; return result;
} }
private string OffsetPage()
{
var skip = this.Skip ?? 1;
var take = this.Take;
this.Skip = null;
this.Take = null;
this.Offset = null;
var pageSql = $"SELECT * FROM ( SELECT PAGETABLE1.*,ROWNUM PAGEINDEX FROM( {this.ToSqlString()}) PAGETABLE1 WHERE ROWNUM<={skip + take}) WHERE PAGEINDEX>={(skip == 0 ? skip : (skip + 1))}";
return pageSql;
}
public override string ToPageSql(string sql, int? take, int? skip, bool isExternal = false) public override string ToPageSql(string sql, int? take, int? skip, bool isExternal = false)
{ {
string temp = isExternal ? ExternalPageTempalte : PageTempalte; string temp = isExternal ? ExternalPageTempalte : PageTempalte;