Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
795bcb3053
  1. 4
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

4
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -247,7 +247,9 @@ namespace SqlSugar
}
var isRowNumber = Skip != null || Take != null;
var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString);
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null);
string groupByValue = GetGroupByString + HavingInfos;
string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null;
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue);
sql.Replace("{$:OrderByString:$}", isRowNumber ? (this.IsCount ? null : rowNumberString) : null);
if (IsCount) { return sql.ToString(); }
var result = ToPageSql(sql.ToString(), this.Take, this.Skip);

Loading…
Cancel
Save