Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analyzing a Linq expression

I would like to know if an IQueryable object's Expression contains a certain "Where clause".

For example, given as IQueryable instance, which could be something like:

var query = customers.Where(c => c.Name == "Test");

How can I determine if the query is filtering the customers by Name?

like image 356
David Martines Avatar asked Oct 11 '22 05:10

David Martines


1 Answers

You have to walk the expression tree (IQueryable.Expression), if you are on .NET4 ExpressionVisitor class helps.

like image 192
Just another metaprogrammer Avatar answered Oct 17 '22 23:10

Just another metaprogrammer