title: Error while flattening the IQueryable<T> after GroupBy()
body: <p>I am trying to get flattened object from the database, but I get an error. I want to get 2 books for all genres in the database, the code looks like this:</p>
  <pre class="lang-cs prettyprint-override"><code>IQueryable&lt;Book&gt; query = _context.Books
                                   .GroupBy(b =&gt; b.Genre)
                                   .SelectMany(bc =&gt; bc.Select(b =&gt; b).Take(2));
  </code></pre>
  <p>Does anyone know what am I doing wrong in here?</p>
  <p>I get this exception instead of a result :</p>
  <blockquote>
  <p>The LINQ expression '<code>bc =&gt; bc .AsQueryable() .Select(b =&gt; b) .Take(2)</code>' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See go.microsoft.com/fwlink/?linkid=2101038 for more information.</p>
  </blockquote>
  <p>I tried also something like that :</p>
  <pre><code>IQueryable&lt;Book&gt; query = _context.Genres.GroupJoin(
       _context.Books,
       g =&gt; g,
       b =&gt; b.Genre,
       (g, books) =&gt; new
       {
           Genre = g,
           BookCollection = books
       }
      ).SelectMany(bc =&gt; bc.BookCollection.Select(b =&gt; b)
      .Take(2)).Include(b =&gt; b.Author).Include(b =&gt; b.Rating)
               .Include(b =&gt; b.BookISBNs).Include(b =&gt; b.Reviews)
               .ThenInclude(r =&gt; r.User);
  </code></pre>