title: Get child item using linq
body: <p>I have categories and subcategories and I return data in Stored procedure like:</p>
  <pre><code>  SELECT
                   [RC].[Name] AS 'CategoryName'
                  , [RS].[Name] AS 'SubcategoryName'
                   FROM [RedMarkCategory] AS [RC]
                       INNER JOIN [RedMarkSubcategory] AS [RS] ON [RC].[RedMarkCategoryId] = [RS].[RedMarkCategoryId]
                       WHERE RS.IsDeleted = 0
              ORDER BY
                     [RC].[Name]
  </code></pre>
  <p>OUTPUT:</p>
  <p><a href="https://i.stack.imgur.com/TC3rm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TC3rm.png" alt="enter image description here" /></a></p>
  <p>As you can see one category can have multiple subcategories.</p>
  <p>So in c# I first get Categories to create <code>GroupBoxes</code> dinamically and inside GroupBox I want to create <code>Checkboxes</code> foreach subcategorie :</p>
  <pre><code>DataTable dataFromDb = GetData();
  
              string[] distinctCetgories = dataFromDb.AsEnumerable()
          .Select(x =&gt; x.Field&lt;string&gt;(&quot;CategoryName&quot;)).Distinct().ToArray();
  
  
      
  
  foreach (var itm in distinctCetgories)
          {
              // extract all the subcategories for the checkboxes inside the groupbox
              string[] subcategories = dataFromDb.AsEnumerable().
                  Where(x =&gt; x.Field&lt;string&gt;(&quot;SubcategoryName&quot;) == itm).
                  Select(y =&gt; y.Field&lt;string&gt;(&quot;SubcategoryName&quot;)).ToArray();
  
              flpRedMarks.Controls.Add(GetGroupBox(itm, subcategories, 200, 100));
          }
  </code></pre>
  <p>Categories are created successfull but  subcategorie query is allways 0:</p>
  <pre><code>string[] subcategories = dataFromDb.AsEnumerable().
                      Where(x =&gt; x.Field&lt;string&gt;(&quot;SubcategoryName&quot;) == itm).
                      Select(y =&gt; y.Field&lt;string&gt;(&quot;SubcategoryName&quot;)).ToArray();
  </code></pre>
  <p>So I always get empty checkboxes:</p>
  <p><a href="https://i.stack.imgur.com/seGsB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/seGsB.png" alt="enter image description here" /></a></p>
  <p>What is wrong with my query? Regards</p>