title: Hierarchical list based on parent_id using C# / LINQ
body: <p>I have the following List:</p>
  
  <pre><code> List&lt;CommentWithUser&gt; flattened = new List&lt;CommentWithUser&gt;();
  </code></pre>
  
  <p>The Class:</p>
  
  <pre><code>public class CommentWithUser
  {
     public comment Comment { get; set; }
     public user User { get; set; }
  }
  </code></pre>
  
  <p>I want to be able to create an structured hierarchical list , where each  comment is under its parent_id comment.</p>
  
  <p>I tried using <a href="http://www.scip.be/index.php?Page=ArticlesNET18" rel="nofollow">this extension class</a> but without success and don't know how to proceed from this point on.</p>
  
  <p>Her's the <code>comment</code> class:</p>
  
  <pre><code>public partial class comment
  {
      public decimal id { get; set; }
  
      public long user_id { get; set; }
      public System.DateTime created { get; set; }
      public byte status_id { get; set; }
      public long reply_to_user_id { get; set; }
      public Nullable&lt;decimal&gt; parent_comment_id { get; set; }
      public string content { get; set; }
      public int spam_reports { get; set; }
      public Nullable&lt;decimal&gt; root_id { get; set; }
  }
  </code></pre>
  
  <p>Note: the comment is multi-threaded = more than two levels structure.
  Using: ASP.NET 4.5/C#/Entity Framework 6</p>