Hi all, I am not an Expression Tree master by any stretch of the imagination, what I have is code that looks like this:
int external = 10;
using(var session = new Session())
{
session.Add(new Product { Name = "test1", Price = 20 });
session.Add(new Product {Name = "test", Price = 10});
var product = session.Products.Where(p => p.Price == external).FirstOrDefault();
Assert.Equal(10, product.Price);
}
Session implements all the IQueryProvider, IQueryable interfaces you'd come to expect from a LINQ Provider.
When I evaluate the expression tree, everything goes to plan until I read the ConstantExpression for "external", at which point, I am at a loss as to how to move forward because:
//constant is ConstantExpression for "external" on the right side of the "p.Price == external" expression above.
var t = constant.GetType(); //evaluates to class called "<>c__DisplayClass2" - with a member named "external" that has the value 10.
The question is basically.. How can I just access the value of the member "external" - is there a way to accomplish this without using reflection? or am I cooked? What am I missing?