Browse Source

Update exp to sql

pull/27/head
sunkaixuan 2 years ago
parent
commit
2ec64ec04e
  1. 16
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs
  2. 16
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs

16
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs

@ -559,5 +559,21 @@ namespace SqlSugar
}
return false;
}
internal static bool IsIsNullSubQuery(Expression it)
{
if (it is MethodCallExpression)
{
var method = (MethodCallExpression)it;
if (method.Method.Name == "IsNull")
{
if (method.Arguments.Count==2&&IsSubQuery(method.Arguments[0]))
{
return true;
}
}
}
return false;
}
}
}

16
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs

@ -116,6 +116,22 @@ namespace SqlSugar
}
}
}
else if (this.Context.IsSingle && args.Any(it => ExpressionTool.IsIsNullSubQuery(it)) )
{
var exp = base.BaseParameter?.BaseParameter?.BaseParameter?.CurrentExpression;
if (exp is LambdaExpression)
{
SetShortName(exp);
}
else if (exp is UnaryExpression)
{
exp = base.BaseParameter?.BaseParameter?.BaseParameter?.BaseParameter?.CurrentExpression;
if (exp is LambdaExpression)
{
SetShortName(exp);
}
}
}
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
var isConst = item is ConstantExpression;
var isIIF = name == "IIF";

Loading…
Cancel
Save