title: String.StartsWith not working with tilde ("~") characters LINQ to SQL?
body: <p>For some reason, my call to IEnumerable.Where() using String.StartsWith() appears to be giving different results depending on whether it's being used in LINQ-to-SQL or standard LINQ (-to-objects). If I add in a call to ToList() on what's otherwise the same call, I get different results back:</p>
  
  <pre><code>var withToList = MyDataContext.MyEntities.ToList().Where(entity =&gt; entity.Name.StartsWith("~Test: My Test String"));
  // withToList.Count() returns 5, which is what I expect.
  var direct = MyDataContext.MyEntities.Where(entity =&gt; entity.Name.StartsWith("~Test: My Test String"));
  // direct.Count() returns 0
  </code></pre>
  
  <p>It's my understanding that, unlike some of the other operators/methods in LINQ, the Where() method does <em>not</em> require the predicate to be SQL-translatable; it's executed on the client side and thus can be arbitrary .NET code. (I've certainly thrown other non-SQL code at it with successful results). I've even got a link where <a href="http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/128fe4cf-776d-4200-9f48-7f8dd30dcb34" rel="nofollow noreferrer">Anders himself</a> suggests that this should be working. What the heck?</p>
  
  <p>EDIT: I've figured out the problem; it has to do with the presence of a tilde in my search string. I've updated the title to reflect this.</p>