Reputation: 383
I'm developing a custom linq provider following the very helpful article found at https://msdn.microsoft.com/en-us/library/bb546158.aspx
However, I'm getting stuck when it comes to the 'Not' operator. For example, I am testing with the condition !a.Name.Equals("2 Test")
. This translates to the lambda expression {Not(a.Name.Equals("2 Test"))}
.
When I call ExpressionVisitor.Visit(expression)
, on this expression, my VisitMethodCall
override is called. However, the MethodCallExpression
parameter received by that call is missing the Not part of the expression, ie: {a.Name.Equals("2 Test")}
.
No other overrides are called (I have overriden all that are available). This seems to make it impossible to handle the Not
part of the expression - however I'm sure that this cannot be the case!
Can anyone shed any light on this for me? AHA, Ben :)
Upvotes: 2
Views: 681
Reputation: 5415
That's because Not
is an unary expression and so the VisitUnary method is called first.
Upvotes: 4