I have a linq query. I have a bunch of parameters from a form I collect where I need to filter based of fields the user is searching for.
IQueyable<Users> user = from user in edmxObject.Users
where user.FirstName.Contains(model.FirstName ?? user.FirstName)
&& user.UserName.Contains(model.UserName ?? user.UserName)
I have a few more non string field filters I need to filter including long and boolean. They could be nulls if the user does not select anything. How do I include them in the query.
This is one of the best examples of why LINQ is so powerful – deferred execution. You can build up the query in different phases, and only when the query is finally executed or resolved will the SQL statement be generated: