title: Linq SelectMany in Entity Framework
body: <p>I'm using Entity Framework. My typical access functionality would be something like this:</p>
  
  <pre><code>    public IEnumerable&lt;Product&gt; Category(string category, int term)
      {
          using (var uow = new UnitOfWork(Connections.LoanComparision))
          {
              var r = new Repository&lt;Product&gt;(uow.Context);
  
              return r.Find(x =&gt; x.Category == category)
                  .Include(x =&gt; x.ProductDetails)
                  .Include(x =&gt; x.ProductRates)
                  .Include(x =&gt; x.Provider)
                  .ToList();
          }
      }
  </code></pre>
  
  <p>You will note from the code above 2 things.</p>
  
  <ul>
  <li>The query returns a list of products with a category including linked
  entities.</li>
  <li>There are a number of ProductDetail lines for each Product.</li>
  </ul>
  
  <p>What I want to do (and haven't been able to work out) is to apply selection criteria on the ProductDetails table.</p>
  
  <p>The stuff inside .Find (my function) can be replaced by a standard .Where clause, but I need to filter on MinTerm and MaxTerm (which is in ProductDetails) yet still return the complete Product dataset (including linked entities), not just ProductDetails.</p>
  
  <pre><code>Where(x =&gt; term &gt;= x.MinTerm &amp;&amp; term &lt;= x.MaxTerm)
  </code></pre>
  
  <p>I can work out how to do it by referencing ProductDetails first and linking to other tables but can't in this configuration. Is it possible?</p>