title: How to tell Linq to Entities to use 'Like' for string equality?
body: <h2>The Question</h2>
  
  <p>When I write with Linq to entities </p>
  
  <pre><code>context.MyTable.Where(t =&gt; t.Name == "Test");
  </code></pre>
  
  <p>it translates to the following sql: </p>
  
  <pre><code>select * from MyTable where Name = 'Test'
  </code></pre>
  
  <p>I want to write an expression in Linq to entities that will translate to: </p>
  
  <pre><code>select * from MyTable where Name like 'Test'
  </code></pre>
  
  <p>Is there some way to achieve that?</p>
  
  <p>Note- I also tried <code>Equals</code> and <code>CompareTo == 0</code> but to no avail.</p>
  
  <h2>The back story</h2>
  
  <p>The reason I want to use <code>Like</code> instead of <code>=</code> is because of the fact that white spaces are ignored at the end of the string if you use <code>=</code>, but it works if you use <code>Like</code> (see this question: <a href="https://stackoverflow.com/questions/17876478/why-the-sql-server-ignore-the-empty-space-at-the-end-automatically">Why the SQL Server ignore the empty space at the end automatically?</a>, and also this: <a href="https://stackoverflow.com/questions/23613930/linq-to-entity-comparing-strings-ignores-white-spaces">Linq to Entity comparing strings ignores white spaces</a>).</p>
  
  <h2>Edit: Why it's not a duplicate of <a href="https://stackoverflow.com/questions/835790/how-to-do-sql-like-in-linq">How to do SQL Like % in Linq?</a></h2>
  
  <p>That question asks for like %, which can be done with <code>Contains/StartsWith/EndsWith</code>, but it's not the same question, I want complete equality so those will not help me.
  There was an answer on that question that did look promising though, using <code>SqlMethods.Like</code>, so I tried </p>
  
  <pre><code>context.MyTable.Where(t =&gt; SqlMethods.Like(t.Name, "Test")
  </code></pre>
  
  <p>but I got the following error: </p>
  
  <blockquote>
    <p>{"LINQ to Entities does not recognize the method 'Boolean Like(System.String, System.String)' method, and this method cannot be translated into a store expression."}</p>
  </blockquote>