title: How to use Linq to check if a string contains one of a subset of strings
body: <p>I have a case where a user is allowed to supply a set of keywords (more preceisely substrings)  when searching for a user name.</p>
  <p>I have something like</p>
  <pre><code>// this set of strings should find names such as john, mary or smith
  List&lt;string&gt; searchStrings=new List&lt;string&gt;(){&quot;jo&quot;,&quot;ma&quot;,&quot;th&quot;}; 
  
  // LINQ query looks like this
  
  var filteredPatients=allPatients.Where(p =&gt;
                              (searchStrings.Any(s=&gt;p.Name.ToLower().Contains(s)));
  </code></pre>
  <p>However this fails and gives the exception:</p>
  <blockquote>
  <p>System.AggregateException : One or more errors occurred. (The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync()</p>
  </blockquote>
  <p>This is running against entityFramework, .NET Core 3.1 against a Postgres Db</p>
  <p>Is there another way to write this query to produce the desired result?</p>
  <p>NOTE:  it would be possible to call ToList() or ToArray() on allPaitents but I would like to avoid this as the whole (very large) table will be read into memory.</p>