title: nested linq queries, how to get distinct values?
body: <p>table data of 2 columns "category" and "subcategory"</p>
  
  <p>i want to get a collection of "category", [subcategories]
  using code below i get duplicates. Puting .Distinct() after outer "from" does not help much. What do i miss?</p>
  
  <pre><code> var rootcategories = (from p in sr.products
                                   orderby p.category
                                    select new
                                    {
                                        category = p.category,
                                        subcategories = (
                                        from p2 in sr.products
                                        where p2.category == p.category
                                        select  p2.subcategory).Distinct()
                                    }).Distinct();
  </code></pre>
  
  <p>sr.products looks like this</p>
  
  <pre><code>category   subcategory
  ----------------------
  cat1       subcat1
  cat1       subcat2
  cat2       subcat3
  cat2       subcat3
  </code></pre>
  
  <p>what i get in results is </p>
  
  <pre><code>cat1, [subcat1,subcat2]
  cat1, [subcat1,subcat2]
  </code></pre>
  
  <p>but i only want one entry</p>
  
  <p>solved my problem with this code:</p>
  
  <pre><code>   var rootcategories2 = (from p in sr.products
                                 group p.subcategory by p.category into subcats
  
                                 select subcats);
  </code></pre>
  
  <p>now maybe it is time to think of what was the right question.. (-:</p>