I am using ASP.NET with C# and I need to make the condition of the query dynamic,
Example:
Database:
Name Sex
--------------
John Doe M
Jane Doe F
Now I want to allow a search on the data set but if the user selects to search by name OR sex only the query will allow a search on the name or sex columns. However if the user selects to search by both name and sex them the query will allow a search by name AND sex column. My question is can I separate the query using if statements to account for the dynamic nature of the search? Thank you.
You can do:
This will filter by sex and/or name depending on what is passed in.
is the same as