How can I make a ParameterExpression for a 1 to * Navigation Property's parent side?
For the child entity, the following functions:
var parameter = Expression.Parameter( typeof(T), // where T is the entity type GetParameterName()); // helper method to get alias
Similar attempts on TParent result in a query coming from the Context rather than a property on the child.
The equivalent in lambda would look like this:
var q = from f in context.Foo where f.Bar.BarId == 1... // where bar is the Navigation Property to the parent
Edit for precision:
I use the next to turn a property into a member expression:
Expression exp = Expression.Equal( Expression.Property(parameter, "SomeColumn"), Expression.Constant("SomeValue"));
It seems that in this instance, MemberExpression should be used instead of ParameterExpression.
I'm not really sure... Zzz-5-Zzz a ".Bar"
- it is a
the argument is. What specifically do you want to do?
One way is to load the example code into Reflector, disable the.NET 3.5 hints, and study how it operates; this will result in code that resembles here but is often simple to understand.