Click here to Skip to main content
15,181,010 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hello

I have read some tutorial about linq to sql and working with stored procedure in linq. Actually a lot of them work on just one parameter and searching on just one table. Now I like to make an advanced search page in ASP.NET with linq data model and advance searching on 4 to 6 parameter (text box, drop down list,) on joined tables. Please help how I can do that, or some sample (application) can be very helpful.

Best regards.
Posted
Comments
Ed Nutting 15-Oct-11 7:09am
   
Search CP articles or usae Google - this has been done, you just have to search a bit.
alimahdipour 15-Oct-11 10:56am
   
Thanks I have searched a lot in Google before but i could not find that. actually i think my "key words" for searching are not correct.please address me one link or good "key word" for searching this title in Google.
thanks in advanced.

1 solution

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.

Hope it gives you some clues.
   
Comments
alimahdipour 16-Oct-11 8:56am
   
Thanks gentleman it gives me very good idea . If I could have some more reference, book address, tutorial or address of sample application about what you mentioned was very helpful.

Thanks in advanced.

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