I'm creating a web application that retrieves data from the database based on the criteria entered. The problem is that I have 10 different search fields and only one of them is required to be filled, the rest can be null.
So what I have is:
Textbox1
Textbox2
..
..
Textbox10
My current query is:
checked = false;
if (Textbox1.Text != null)
{
result = //query here
checked = true;
}
if (Textbox2.Text != null)
{
if(checked==false)
{
result = //new query here
checked = true;
}
else
{
result = results.Where(...new query to filter Textbox2 from previous
query)
}
}
and so on.
How can I build this in one query and ignore the textboxes that don't have values?
Thanks