mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update Group By
This commit is contained in:
parent
b0d995a6b3
commit
c292512649
@ -928,6 +928,7 @@ namespace SqlSugar
|
||||
if (selectSql.Contains(this.GroupBySql))
|
||||
{
|
||||
result = selectSql;
|
||||
this.GroupByIsReplace = true;
|
||||
}
|
||||
}
|
||||
this.SelectCacheKey = result;
|
||||
@ -1096,6 +1097,7 @@ namespace SqlSugar
|
||||
|
||||
#region NoCopy
|
||||
|
||||
internal bool GroupByIsReplace { get; set; }
|
||||
internal List<QueryableFormat> QueryableFormats { get; set; }
|
||||
internal bool IsClone { get; set; }
|
||||
public bool NoCheckInclude { get; set; }
|
||||
|
@ -69,10 +69,6 @@ namespace SqlSugar
|
||||
if (isFirst && oldOrderByValue == "ORDER BY GETDATE() ") { this.OrderByValue = null; }
|
||||
var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString);
|
||||
string groupByValue = GetGroupByString + HavingInfos;
|
||||
if (this.GroupParameters?.Any()==true)
|
||||
{
|
||||
groupByValue = groupByValue.Replace(this.GroupBySqlOld,this.GroupBySql);
|
||||
}
|
||||
string orderByValue = (!isRowNumber && this.OrderByValue.HasValue()) ? GetOrderByString : null;
|
||||
if (isIgnoreOrderBy) { orderByValue = null; }
|
||||
sql.AppendFormat(SqlTemplate, GetSelect(isFirst,isTop), base.GetTableNameString, base.GetWhereValueString, groupByValue, orderByValue);
|
||||
@ -112,6 +108,10 @@ namespace SqlSugar
|
||||
{
|
||||
result = result.Replace("TOP 1 DISTINCT", "TOP 1 ");
|
||||
}
|
||||
if (this.GroupParameters?.Any() == true&&this.GroupByIsReplace)
|
||||
{
|
||||
result = result.Replace(this.GroupBySqlOld, this.GroupBySql);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user