diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs index aee39de80..e2e46b010 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs @@ -49,6 +49,15 @@ namespace SqlSugar { argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand; } + var argLambda = argExp as LambdaExpression; + if (this.Context.InitMappingInfo != null && argLambda != null && argLambda.Parameters.Count > 0) + { + foreach (var item in argLambda.Parameters) + { + this.Context.InitMappingInfo(item.Type); + } + this.Context.RefreshMapping(); + } var result = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")"; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs index 41fd5617f..aeef64ec3 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs @@ -49,6 +49,15 @@ namespace SqlSugar { argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand; } + var argLambda = argExp as LambdaExpression; + if (this.Context.InitMappingInfo != null && argLambda != null && argLambda.Parameters.Count > 0) + { + foreach (var item in argLambda.Parameters) + { + this.Context.InitMappingInfo(item.Type); + } + this.Context.RefreshMapping(); + } var result = "MIN(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")"; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs index 03f1454b4..c6b771583 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs @@ -49,6 +49,15 @@ namespace SqlSugar { argExp =((argExp as LambdaExpression).Body as UnaryExpression).Operand; } + var argLambda = argExp as LambdaExpression; + if (this.Context.InitMappingInfo != null&& argLambda != null&&argLambda.Parameters.Count>0) + { + foreach (var item in argLambda.Parameters) + { + this.Context.InitMappingInfo(item.Type); + } + this.Context.RefreshMapping(); + } var result = "SUM(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple)+")"; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));