I am trying to search a database to see if a string contains elements of a list of search terms.
var searchTerms = new List { \"car\", \"232\"
You can try using Any
method, I'm not sure whether it's supported but it's worth trying:
var result = context.Data.Where(data => searchTerms.Any(x => data.Name.Contains(x)) ||
searchTerms.Any(x => data.Code.Contains(x));
If this gives you NotSupportedException
you can add AsEnumerable
before Where
to fetch all records and execute the query in memory rather than DB.