title: EF Core Linq Query to Select Rows That Match From a List of Possibilities
body: <p>Assume a <code>DbSet&lt;Thing&gt; things</code>; and <code>Thing</code> has a <code>Name</code> property.</p>
  
  <p>If I want to retrieve a list of things that match a list of names, it's pretty straightforward:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var names = new List&lt;string&gt;{"John", "Jacob", "Jinkelheimer", "Smith"};
  
  return things.Where(t =&gt; names.Contains(t.name));
  </code></pre>
  
  <p>However, what if I want to match a list of <em>partial</em> name possibilities?</p>
  
  <pre class="lang-cs prettyprint-override"><code>var nameBits = (new List&lt;string&gt;{"ohn", "mit"}).ToLower();
  
  // this doesn't seem good / right / efficient
  things.Where(t =&gt; nameBits
     .Select(bit =&gt; EF.Functions.Like(t.Name, $"%{bit}%")
     .Any(m =&gt; m)
  );
  
  // I could also go with:
  
  things.Where(t =&gt; nameBits
       .Select(bit =&gt; t.Name.Contains(bit)).Any(m =&gt; m)
  );
  </code></pre>
  
  <p>... but I don't know how efficient any of those will be.
  How would I write the linq query that would efficiently match "John", "Johnathan", "Smith", "Smitty", etc using <code>ohn</code> and <code>mit</code>? </p>