title: How to get a distinct, case-insensitive list using Linq and Entity Framework
body: <p>I need to get a case-insensitive list from the results of an entity framework query. I have the following:</p>
  
  <pre><code> var myList = myEF.GroupBy(e =&gt; new { e.Code, e.Description })
              .Select(e =&gt; e.First())
              .ToList();
  </code></pre>
  
  <p>That gives me a distinct list, but it's case-sensitive. I need case-insensitive.</p>
  
  <p>I figured I should be able to do something like this:</p>
  
  <pre><code>var myList = myEF.GroupBy(e =&gt; new { e.Code, e.Description }, StringComparer.InvariantCultureIgnoreCase)
              .Select(e =&gt; e.First())
              .ToList();
  </code></pre>
  
  <p>But that doesn't seem to want to work with the anonymous object.</p>
  
  <p>Adding <code>.ToLower</code> or <code>.ToLowerInvariant</code> doesn't seem to work either. Nor does using <code>Distinct(StringComparer.InvariantCultureIgnoreCase)</code> instead of the <code>GroupBy</code>.</p>
  
  <p>Seems there ought to be an easy way to do this, but I'm not finding it.</p>