Converting conditionally built SQL where-clause into LINQ?

Var query = from p in persons select p; if (whereCriteria1) { query = from p in query join a in address on p. Addressid equals a. Addressid where a.

State = 'PA' where a. Zip = '16127' select p; } if (whereCriteria2) { query = from p in query join c in colors on p. Favoritecolorid equals c.

Colorid where c. Name = 'blue' select p; }.

That's exactly what I want, thanks – ZombieDev Dec 4 '09 at 19:14.

You're looking for dynamic predicates built at runtime. Here is a good CodeProject article. You may also be interested in this PredicateBuilder.

Sure, the answer is similar to the one I provided for this question. The basic strategy is to define your "base query" and then to conditionally add where clauses to the query.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions