How to create a search function using nhibernate, linq?
I am about to create a search function today, C # asp.net. I need a push to get it rolling. I am using nhibernate linq. it would be nice to do it with a linq query. it should be dynamic, I will have multiple search criteria like gender, email, name, age and some others.
this search term is only suitable for my client object.
How can i do this? and how is it done correctly?
Now I think I am getting an iqueryable and querying this. I think so, for example, for gender, I have two checkboxes, so I execute if a man checks that I do where.gender == "Man", and if none is checked, I do nutting. but is this the way to do it for every request? because some users enter like name, email, age.
please advise me about it
You can parse your search filter like this:
var query==...
if (filter.Name.Length>0)
query=query.Where(name=...)
if (filter.Email.Length>0)
query=query.Where(email=...)