PartialEvaluatingExpressionTreeVisitor breaks while compiling lambda expression which has nested member access and upper member is null.
for example : Property.NestedProperty.Value == something
if Property == null (or NestedProperty == null) EvaluateSubtree will explode.
Here is a fix which works for me:
I've added a check for nested member evaluation and returned constant null if member is null.
While this is not entirely correct, since this part of lambda expression has purged evaluation shortcutting and this is consistent with sql behavior, I think this is accepted behavior.
You can improve this patch by recursively evaluating member expressions to see if some other property is not null.
For example if you have