Ouananiche
Ouananiche

Reputation: 599

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?

Upvotes: 5

Views: 505

Answers (1)

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

Upvotes: 4

Related Questions