title: Difference between == and .Equals() with Interfaces and LINQ
body: <p>I recently got a "The mapping of interface member ..... is not supported" error, which I resolved based on <a href="http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/bc2fbbce-eb63-4735-9b2d-26b4ab8fe589/" rel="noreferrer">this thread</a>.  To demonstrate: </p>
  
  <pre><code>public interface IMyInterface { string valueText { get; set; } }
  public class MyData : IMyInterface
  {
     int ID { get; set;}
     string valueText { get; set;}
  }
  public class MyOtherData : IMyInterface
  {
     long ID { get; set;}
     string valueText { get; set;}
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public static IEnumerable&lt;T&gt; GetByValue&lt;T&gt;(string value) : where T : class, IMyInterface, new()
  { 
     using (var context = new DataContext())
     { 
        // The important line
        return context.GetTable&lt;T&gt;().Where(x =&gt; x.valueText == value);
     }
  }
  </code></pre>
  
  <p>Running this code, I'd get a NotSupportedException: "The mapping of interface member IMyInterface.valueText is not supported".  However, if I replace the <code>x.valueText == value</code> with <code>x.valueText.Equals(value)</code>, this works entirely as expected.</p>
  
  <p>I've solved this in my code, but I want to understand <em>why</em> it behaves this way.  Can anyone explain it?</p>
  
  <p><strong>Update:</strong> As per my comment below, the LINQ to SQL team closed this as a "Won't fix".  I think that means it now counts as a known bug, but one that isn't going to be resolved any time soon.  I'd still like to know why it behaves differently in the first place, though.</p>