title: Using LIKE operator in LINQ to Entity
body: <p>Currently in our project we are using Entity Framework and LINQ. We want to create a search feature where the Client fills different filters but he isn't forced to.</p>
  
  <p>To do this "dynamic" query in LINQ, we thought about using the Like operator, searching either for the field, or "%" to get everything if the user didn't fill that field.</p>
  
  <p>The joke's on us when we discovered it didn't support Like. After some searching, we read several answers where it's sugested to use StartsWith, but it's useless for us.</p>
  
  <p>Is the only solution using something like:</p>
  
  <pre><code>ObjectQuery&lt;Contact&gt; contacts = db.Contacts;
  if (pattern != "")
  {
        contacts = contacts.Where(“it.Name LIKE @pattern”);
        contacts.Parameters.Add(new ObjectParameter(“pattern”, pattern);
  }
  </code></pre>
  
  <p>However, we'd like to stick with linq only.</p>
  
  <p>Happy coding!</p>