diff --git a/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index ded1a2703..5297d7ece 100644 --- a/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -487,12 +487,20 @@ namespace SqlSugar } protected ISugarQueryable _GroupBy(Expression expression) { + LambdaExpression lambda = expression as LambdaExpression; + expression = lambda.Body; var isSingle = QueryBuilder.IsSingle(); - var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple); - string result = lamResult.GetResultString(); - if (result.IsNullOrEmpty()) { - lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.ArraySingle : ResolveExpressType.ArrayMultiple); - result =string.Join(",",lamResult.GetResultArray().Select(it=>this.SqlBuilder.GetTranslationColumnName(typeof(T).Name,it))); + ExpressionResult lamResult = null; + string result = null; + if (expression is NewExpression) + { + lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.ArraySingle : ResolveExpressType.ArrayMultiple); + result = string.Join(",", lamResult.GetResultArray().Select(it => this.SqlBuilder.GetTranslationColumnName(typeof(T).Name, it))); + } + else + { + lamResult=QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple); + result = lamResult.GetResultString(); } GroupBy(result); return this;