title: Strange EF behaviour when passing DbSet to a method with parameter type IEnumerable<>
body: <p>I have a repository class which is querying the EF DbContext like this:</p>
  
  <pre><code>public IEnumerable&lt;ProductFilterData&gt; GetAllProducts()
  {
     return this.DataContext.Products.Select(x =&gt; new ProductFilterData { Id = x.Id, Name = x.Name, ProductDetailLevelCode = x.ProductDetailLevel.Code, Description = x.Description, ParentProductIds = x.ParentProducts.Select(p =&gt; p.Id) });
  }
  </code></pre>
  
  <p>Which works fine. However, when I refactor this code to this:</p>
  
  <pre><code>public IEnumerable&lt;ProductFilterData&gt; GetAllProducts()
  {
      return this.MapToProductFilterData(this.DataContext.Products);
  }
  
  private IEnumerable&lt;ProductFilterData&gt; MapToProductFilterData(IEnumerable&lt;Product&gt; products)
  {
      return products.Select(x =&gt; new ProductFilterData { Id = x.Id, Name = x.Name, ProductDetailLevelCode = x.ProductDetailLevel.Code, Description = x.Description, ParentProductIds = x.ParentProducts.Select(p =&gt; p.Id) });
  }
  </code></pre>
  
  <p>I get an exception:</p>
  
  <blockquote>
    <p>There is already an open DataReader associated with this Command which
    must be closed first.</p>
  </blockquote>
  
  <p>Why does passing a reference to the DbSet to a method cause a change in the behavior of EF? Incidentally, if I change the parameter type of MapToProductFilterData to IQueryable then it works. Also, if I remove the relationship mappings it also works.</p>