I have the following Linq Query:
var query1 = qble1.Where(x => x.name == "name" && x.id == 1);
I am trying to extract the Where
clause into a variable, which I can then reapply to another query when I need to.
To give you a slightly different view (and hopefully not confuse the aim of the question), I can do the following:
Expression<Func<testClass, bool>> whereClause = x => x.name == "name" && x.id == 1;
var query1 = qble1.Where(whereClause);
and this will apply the whereClause
variable to query1
I am trying to achieve the inverse of above, which is to write the query, and the extract the Where Clause into the variable whereClause
eg
Expression<Func<testClass, bool>> whereClause = WhereClause of query1
Can this be done?
The reason I am trying to do this is to solve the issue I am having in this question: