title: Add list of items using linq
body: <p>I have a class that holds Categories.</p>
  
  <pre><code>public class CategoryDto
  {
      public int Id { get; set; }
      public int PortfolioId { get; set; }
      public string Description { get; set; }
      public List&lt;SubCategoryDto&gt; SubCategories { get; set; }
  
      public CategoryDto()
      {
          SubCategories = new List&lt;SubCategoryDto&gt;();
      }
  }
  </code></pre>
  
  <p>It has a List in it, which is a list of SubCategory classes:</p>
  
  <pre><code>public class SubCategoryDto
  {
      public int Id { get; set; }
      public int CategoryId { get; set; }
      public CategoryDto Category { get; set; }
      public string Description { get; set; }
  }
  </code></pre>
  
  <p>I then populate this item, but I am getting a list bases on a 'PortfolioId'.</p>
  
  <pre><code>   var cats = (from p in Context.transaction_category
                      where p.account_portfolio_id == portfolioId
                            &amp;&amp; p.deleted == null
                      select new CategoryDto
                          {
                              Id = p.id,
                              Description = p.description,
                              PortfolioId = p.account_portfolio_id
                          }).ToList();
  </code></pre>
  
  <p>The Categories table has a foreign key to SubCategories. Each category has 0:n sub categories. So, the entity framework model has a <code>Context.transaction_category.transaction_sub_categories</code> collection.</p>
  
  <p>So now what I do is, foreach through the categories in the list above, and populate the sub categories.</p>
  
  <p>Is there a way to do this in the same link statement? The Categories object has a List list. Can it be done in the above Linq statement?</p>
  
  <p>Edit:
  This is the fix attempt, as recommended, but is presenting an error:</p>
  
  <pre><code>var cats = (from p in Context.transaction_category
                          where p.account_portfolio_id == portfolioId
                                &amp;&amp; p.deleted == null
                          select new CategoryDto
                              {
                                  Id = p.id,
                                  Description = p.description,
                                  PortfolioId = p.account_portfolio_id,
                                  SubCategories = (from s in Context.transaction_sub_category where s.transaction_category_id == p.id
                                                   &amp;&amp; s.deleted == null
                                                       select new SubCategoryDto
                                                           {
                                                               Id = s.id,
                                                               Description = s.description,
                                                               CategoryId = s.transaction_category_id
                                                           }).ToList()
                              }).ToList();
  </code></pre>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method
    'System.Collections.Generic.List<code>1[Objects.SubCategoryDto]
    ToList[SubCategoryDto](System.Collections.Generic.IEnumerable</code>1[Objects.SubCateg‌​oryDto])'
    method, and this method cannot be translated into a store expression.</p>
  </blockquote>