The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience. (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.