title: EF issue with grouping on server
body: <p>I ran into this problem when I was doing group by with entity framework.</p>
  
  <p>.Net: 4.5, EF: 5.0, Database: Oracle</p>
  
  <p>My problem was when I was grouping on the server and getting back the data, the grouped data (list of entities) was returning the first record over and over for all the grouped data - but the group KEY was correct.</p>
  
  <p>If I don't do a group by the records return as expected, but I have some grouping requirements and my workaround is ... yeah not making me feel that good and the code should work... but it does not.</p>
  
  <p>x.D = string rest is integer/string mix.</p>
  
  <p>Here is the code that did not work:</p>
  
  <pre><code>db.ENTITY_NAME
  .Where(x =&gt;
         wantedGs.Contains(x.G) &amp;&amp;
         wantedAs.Contains(x.A)
      )
  .GroupBy(x =&gt; x.D)
  .ToList()
  .Select(x =&gt; x.FirstOrDefault())
  .Select(x =&gt; new MyEntity
      {
          A = x.A,
          B = x.B,
          C = x.C,
          E = x.E,
          D = x.D,
          F = x.F,
          G = x.G
      })
  .ToList();
  </code></pre>
  
  <p>Here is the workaround I managed to do what I want:</p>
  
  <pre><code>db.ENTITY_NAME
  .Where(x =&gt;
         wantedGs.Contains(x.G) &amp;&amp;
         wantedAs.Contains(x.A)
      )
  .Select(x =&gt; new
  {
      x.A,
      x.B,
      x.C,
      x.D,
      x.E,
      x.F,
      x.G
  })
  .ToList()
  .GroupBy(x =&gt; x.D)
  .Select(x =&gt; x.FirstOrDefault())
  .Select(x =&gt; new MyEntity
      {
          A = x.A,
          B = x.B,
          C = x.C,
          E = x.E,
          D = x.D,
          F = x.F,
          G = x.G
      })
  .ToList();
  </code></pre>