Browse Source

Update subquery bug

pull/3/head
sunkaixuna 3 years ago
parent
commit
5b425c1ce8
  1. 9
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs
  2. 9
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs
  3. 9
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs

9
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));

9
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));

9
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));

Loading…
Cancel
Save