It appears that the VB compiler and the C# compiler generate the expression tree differently. When I originally wrote the lambda prefetch code, I only tested with C#
VB generates UnaryExpressions which wrap the MemberExpressions, while C# just generates the MemberExpressions.
If you have access to the LinqSupportClasses source code, I think the following changes should fix it (I haven't tested it though):
// PathEdgeRootParser.cs line 114
return ParseComplexPathSpecification<TDestination>(expression.Body as MemberExpression);
//PathEdgeRootParser.cs line 125
ParseSimplePathSpecification(expression.Body as MemberExpression);
needs to become...
// PathEdgeRootParser.cs line 114
return ParseComplexPathSpecification<TDestination>(RemoveUnary(expression.Body));
//PathEdgeRootParser.cs line 125
ParseSimplePathSpecification(RemoveUnary(expression.Body));
...and the following method needs to be added to PathEdgeRootParser.cs:
private static MemberExpression RemoveUnary(System.Linq.Expressions.Expression toUnwrap)
{
if(toUnwrap is UnaryExpression)
{
return (MemberExpression)((UnaryExpression)toUnwrap).Operand;
}
return toUnwrap as MemberExpression;
}