|
@ -247,7 +247,9 @@ namespace SqlSugar |
|
|
} |
|
|
} |
|
|
var isRowNumber = Skip != null || Take != null; |
|
|
var isRowNumber = Skip != null || Take != null; |
|
|
var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString); |
|
|
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); |
|
|
sql.Replace("{$:OrderByString:$}", isRowNumber ? (this.IsCount ? null : rowNumberString) : null); |
|
|
if (IsCount) { return sql.ToString(); } |
|
|
if (IsCount) { return sql.ToString(); } |
|
|
var result = ToPageSql(sql.ToString(), this.Take, this.Skip); |
|
|
var result = ToPageSql(sql.ToString(), this.Take, this.Skip); |
|
|