Browse Source

Update SubQuery BUG

pull/12/MERGE
610262374@qq.com 6 years ago
parent
commit
38b107895a
  1. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs
  2. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs
  3. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs

@ -43,7 +43,11 @@ namespace SqlSugar
public string GetValue(Expression expression = null)
{
var exp = expression as MethodCallExpression;
return "MAX("+SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle)+")";
var argExp = exp.Arguments[0];
var result = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, string.Empty);
return result;
}
}
}

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs

@ -43,7 +43,11 @@ namespace SqlSugar
public string GetValue(Expression expression = null)
{
var exp = expression as MethodCallExpression;
return "MIN(" + SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle) + ")";
var argExp = exp.Arguments[0];
var result = "MIN(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, string.Empty);
return result;
}
}
}

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs

@ -43,7 +43,11 @@ namespace SqlSugar
public string GetValue(Expression expression = null)
{
var exp = expression as MethodCallExpression;
return "SUM("+SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle)+")";
var argExp = exp.Arguments[0];
var result = "SUM(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple)+")";
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, string.Empty);
return result;
}
}
}

Loading…
Cancel
Save