mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Synchronization code
This commit is contained in:
parent
66fc3358b5
commit
1618ed8bbb
@ -26,6 +26,12 @@ namespace SqlSugar
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
public static bool ContainsMethodName(BinaryExpression expression, string name)
|
||||
{
|
||||
var visitor = new MethodCallExpressionVisitor(name);
|
||||
var hasMethodCallWithName = visitor.HasMethodCallWithName(expression);
|
||||
return hasMethodCallWithName;
|
||||
}
|
||||
public static bool IsVariable(Expression expr)
|
||||
{
|
||||
var ps = new ParameterExpressionVisitor();
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
@ -17,4 +18,31 @@ namespace SqlSugar
|
||||
return base.VisitParameter(node);
|
||||
}
|
||||
}
|
||||
internal class MethodCallExpressionVisitor : ExpressionVisitor
|
||||
{
|
||||
private readonly string _methodName;
|
||||
private bool _hasMethodCallWithName;
|
||||
|
||||
public MethodCallExpressionVisitor(string methodName)
|
||||
{
|
||||
_methodName = methodName;
|
||||
}
|
||||
|
||||
public bool HasMethodCallWithName(Expression expression)
|
||||
{
|
||||
Visit(expression);
|
||||
return _hasMethodCallWithName;
|
||||
}
|
||||
|
||||
protected override Expression VisitMethodCall(MethodCallExpression node)
|
||||
{
|
||||
if (node.Method.Name.Contains(_methodName))
|
||||
{
|
||||
_hasMethodCallWithName = true;
|
||||
return node;
|
||||
}
|
||||
|
||||
return base.VisitMethodCall(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,16 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
var selector = GetNewExpressionValue(rightExpression.Arguments[0]);
|
||||
var selector = "";
|
||||
bool hasMethodCallWithName = ExpressionTool.ContainsMethodName(expression, "Join");
|
||||
if (hasMethodCallWithName)
|
||||
{
|
||||
selector = GetNewExpressionValue(rightExpression.Arguments[0], ResolveExpressType.WhereMultiple);
|
||||
}
|
||||
else
|
||||
{
|
||||
selector = GetNewExpressionValue(rightExpression.Arguments[0]);
|
||||
}
|
||||
var selectorExp = rightExpression.Arguments[0];
|
||||
if (selector.Contains(".") && selectorExp is LambdaExpression)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user