Is there an equivalent “*” for Contains(““)? I’m using some wildcards for filtering and if there isn’t a filter applied then I need to return all?
string[] filter = {1,2}; // This is dynamic could be filtered values or {} empty.
// This works for filtering by products (1,2)
db.Products.Where(x => filter.Contains(x.ProdId));
What I really need to achieve is something like this:
// If the filter is empty get all results...if there is a filter passed the filter values in for select
db.Products.Where(x => x.ProdId.Contains(filter.Length == 0 ? "*" : filter);
Use this:
If the filter is not the only where condition, that’s not a problem at all, you can define multiple
Wheres for your query: