title: creating a category list using linq
body: <p>I have the following List which contains the following collection. </p>
  
  <p>How i can transform this with linq so that i get nested items. </p>
  
  <pre><code> var categories = new List&lt;Category&gt;(); // id, parentId, name
          categories.Add(1, 0, "Sport");
          categories.Add(2, 0, "Pets");
          categories.Add(3, 1, "Foot ball");
          categories.Add(4, 2, "Cat");
          categories.Add(5, 3, "Pele");
          categories.Add(6, 4, "whiskers");
          // ie Pets - &gt; Cat - &gt; Whiskers
  
  
  
  
  
     public class Category
      {
  
          public int Id { get; set; }
          public int ParentId { get; set; }
          public ICollection&lt;Category&gt; Categories { get; set; }
  
      }
  </code></pre>