Click here to Skip to main content
15,918,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I am new to line before I had question about "Advance Search Page" and how I can search by 3 or 4 conditions in LINQ. Answer to me was like below and understandable for me.
Now after making some search in Google about "dynamic query" they have referred to some address like below that seem complicate.
Now I don't know which is better and which I have to select please help.

Best regards.


1-Answered question:

" You should make your search tables into a one single view by joining them as much as possible(in Database)
After bringing your view into data layer and business layer you can apply the criteria by LINQ expressions very easily.
Just separate search items by AND operators.
So when user clicks on search button you should do something like this :

... MySearchView.Where(i=> i.Name == NameCriteria.Text && i.Country == DropDownList.SelectedVaule && ... );

or if your Data layer supports navigation do something like this :

... Country.Where(i => i.Country == DropDownList.SelectedVaule).Students.Where(i=> i.Name == NameCriteria.Text ) ...

(take care of null result in each step)

and redirect the results to a grid or something like that."

2-how to easily build dynamic LINQ to SQL queries at run-time in C# on his web site. See http://tomasp.net/blog/dynamic-linq-queries.aspx.

3-Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) by ScottGu's Blog
Posted
Updated 17-Oct-11 8:45am
v2

Which have you tried?
Which have you tried to customize toward the style of searches you would need them to do? which one of the methods are you most comfortable with?

For me once you can answer these questions you will know most of the answer yourself, but it is a case of exploration.
 
Share this answer
 
I tried the #3, and it works. My experience with it was not bad at all, but in the end I did not need its full power. I ended up composing query expressions manually: the native LINQ API[^] was simple enough to adopt for my case.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900