(11) [Avatar] Offline
I like to make advanced search page with text box, drop down listÂ… so I think "Listing 5.16: Complete version of the Conditional Query method that tests for the provided criteria" is very suitable for me. Also in this chapter used another way, using expression tree. Also in the note referenced:
"Tomas Petricek, a C# MVP, shows how to easily build dynamic LINQ to SQL queries at run-time in C# on his web site. See"

Now I have some problem:
1- I do not know which way is better, actually first way is understandable for me and second a bit complicate and third very complicate.
2- I have some related tables, I do not know by expression tree how I have to do that. By first way it seems by join query I can do that.
3- I am afraid if I select first way, in the future I will have problem because I do know well expression tree andÂ….
4- Is necessary just working with expression tree in some situation?

Please help me in this situation (I am new to linq).
Best regards.
fabrice.marguerie (224) [Avatar] Offline
Re: difference between query method & expression tree in (listing 5.16)
The first solution we show in the book is simpler to use and understand, however, it doesn't allow you to do such things as OR operations. Tomas Petricek's solution does.
You don't have to use the more complex/powerful solution all the time. Quite often, the simpler one will be enough. When it's not the case, go with the other solution.
You don't have to make a hard choice at the beginning.