From f0881ba672b1ebcccb246ee8a2467efed7770c84 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 12 Sep 2017 13:47:10 +0800 Subject: [PATCH] - --- .../SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs index 0c8761cd4..01cada44a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs @@ -225,6 +225,7 @@ namespace SqlSugar { string oldOrderBy = this.OrderByValue; string externalOrderBy = oldOrderBy; + var isCount = this.IsCount; AppendFilter(); sql = new StringBuilder(); if (this.OrderByValue == null && (Skip != null || Take != null)) this.OrderByValue = " ORDER BY GetDate() "; @@ -236,10 +237,10 @@ namespace SqlSugar var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString); string groupByValue = GetGroupByString + HavingInfos; string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null; - if (this.IsCount) { orderByValue = null; } + if (isCount) { orderByValue = null; } sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue); sql.Replace(UtilConstants.ReplaceKey, isRowNumber ? (this.IsCount ? null : rowNumberString) : null); - if (this.IsCount) { this.OrderByValue = oldOrderBy; return sql.ToString(); } + if (isCount) { this.OrderByValue = oldOrderBy; return sql.ToString(); } var result = ToPageSql(sql.ToString(), this.Take, this.Skip); if (ExternalPageIndex > 0) {