Update subquery bug

This commit is contained in:
sunkaixuna
2021-06-19 11:22:37 +08:00
parent e092aa091d
commit 5b425c1ce8
3 changed files with 27 additions and 0 deletions

View File

@@ -49,6 +49,15 @@ namespace SqlSugar
{ {
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand; 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 result = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));

View File

@@ -49,6 +49,15 @@ namespace SqlSugar
{ {
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand; 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 result = "MIN(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));

View File

@@ -49,6 +49,15 @@ namespace SqlSugar
{ {
argExp =((argExp as LambdaExpression).Body as UnaryExpression).Operand; 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 result = "SUM(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple)+")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));