title: LINQ to determine if children exist
body: <p>For simplicity, a "Section" object contains the following properties:</p>
  
  <pre><code>SectionId
  ParentSectionId
  Name
  </code></pre>
  
  <p>I currently have the following LINQ code to obtain child sections of a given section:</p>
  
  <pre><code>List&lt;Section&gt; sections = SectionCache.GetAllSections();
  
  sections.AsQueryable().Where(s =&gt; s.ParentSectionId == 10);
  </code></pre>
  
  <p>This gives me all children of the section with a SectionId of 10 (again, for simplicity), but I need to develop this further to only include sections that themselves have children. In SQL, I might do something like this:</p>
  
  <pre><code>SELECT      Section.SectionId,
              Section.ParentSectionId,
              Section.Name
  FROM        Section
  INNER JOIN  Section children ON children.ParentSectionId = Section.SectionId
  WHERE       Section.ParentSectionId = 10
  GROUP BY    Section.SectionId,
              Section.ParentSectionId,
              Section.Name
  HAVING      COUNT(children.SectionId) &gt; 0
  </code></pre>
  
  <p>How can I achieve this in LINQ/what is the best way to achieve this with LINQ?</p>
  
  <p>Thanks</p>