Synchronization code

This commit is contained in:
sunkaixuan 2022-10-13 10:35:50 +08:00
parent fd7cb5beed
commit 2cc36304c5
4 changed files with 22 additions and 5 deletions

View File

@ -1999,6 +1999,7 @@ namespace SqlSugar
{ {
if (this.Context.CurrentConnectionConfig.DbType != DbType.SqlServer) if (this.Context.CurrentConnectionConfig.DbType != DbType.SqlServer)
{ {
this.QueryBuilder.Offset = "true";
return this.ToPageList(pageIndex, pageSize); return this.ToPageList(pageIndex, pageSize);
} }
else else

View File

@ -22,6 +22,10 @@ namespace SqlSugar
} }
public override string ToSqlString() public override string ToSqlString()
{ {
if (this.Offset == "true")
{
return OffsetPage();
}
var oldTake = Take; var oldTake = Take;
var oldSkip = Skip; var oldSkip = Skip;
var isDistinctPage = IsDistinct && (Take > 1 || Skip > 1); var isDistinctPage = IsDistinct && (Take > 1 || Skip > 1);
@ -50,6 +54,18 @@ namespace SqlSugar
} }
return result; return result;
} }
private string OffsetPage()
{
var skip = this.Skip;
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 string _ToSqlString() public string _ToSqlString()
{ {
string oldOrderBy = this.OrderByValue; string oldOrderBy = this.OrderByValue;