Resolving PropertyExpressions and FieldExpressions in a custom Linq provider RRS feed

  • Question

  • I’m writing a custom Linq provider and when I am processing the expression and I have passed in something like this:


    var basket = basketContext.Single(p => p.Name == “MyBasketName”);


    I am able to resolve it as a “ConstantExpression”.


    However, if I pass in something like this:

    var basket = basketContext.Single(p => p.Name == ServiceProxy.BasketName);


    where I am passing in a property instead of a constant, I am not able to parse the expression to it’s underlying value.

    It exceptions, telling me it is a “System.Linq.Expressions.PropertyExpression”, however there doesn’t seem to be any such thing.

    I have Binged around and not seen any documentation or details or examples of how to resolve.

    If I pass in a field, instead of a property, it tells me it is a “System.Linq.Expressions.FieldExpression” which also doesn’t seem to exist.


    Am I missing an assembly with extensions for these expression types?

    Can anyone provide some guidance on how to resolve these property and field expression types to their underlying values?

    Tuesday, August 31, 2010 10:46 PM

All replies

  • PropertyExpression is internal.  Instead try casting it to PropertyExpression's base class: System.Linq.Expressions.MemberExpression.

    Tuesday, November 30, 2010 6:38 PM