I have a List<string> filterCriteria which contains one or multiple keywords to search a column in my database with based on user selection on the client side.
The problem i have is that im not quite sure on how to build my linq to sql statement as it could have no ‘or’ operator or it could have multiple (10+).
This is my original query
var originalQuery = (from p in productContext.Products
select p);
Then based on the list i need to query ‘originalQuery’ by the words in my List<string> filterCriteria using or operators.
E.g.
originalQuery = originalQuery.Where(p => p.ProductRange == "criteria1" ||
p.ProductRange == "criteria2");
And so on…
You could do it like this:
This way, you will get all items in the originalQuery which have one of the selected values for ProductRange.