How to create objects with retrieved Hierarchical result set?
<p>I am using C# language. My problem is that i don't know how to store my retrieved hierarchical result set to my object.</p>

<p>Here's is my Object:</p>

<pre><code>public class CategoryItem
{
    public string Name { get; set; }
    public int CategoryID { get; set; }
    public int ParentID { get; set; }
    public List&lt;CategoryItem&gt; SubCategory = new List&lt;CategoryItem&gt;();
    public List&lt;CategoryItem&gt; GetSubCategory()
    {
        return SubCategory;
    }
    public void AddSubCategory(CategoryItem ci)
    {
        SubCategory.Add(ci);
    }
    public void RemoveSubCategory(CategoryItem ci)
    {
        for (int i = 0; i &lt; SubCategory.Count; i++)
        {
            if (SubCategory.ElementAt(i).CategoryID == ci.CategoryID)
            {
                SubCategory.RemoveAt(i);
                break;
            }
        }
    }
}
</code></pre>

<p>Here's is my sample retrieve data set from MSSQL server</p>

<pre><code>ID  PrntID  Title   
_______ _______     
1   0   Node1   
2   1   Node2   
3   1   Node3   
4   2   Node4   
5   2   Node5   
6   2   Node6   
7   3   Node7   
8   4   Node8   
9   4   Node9   
10  9   Node10
</code></pre>

<p>Tree view for easy reference</p>

<pre><code>Node 1
-Node 2
--Node 4
---Node 8
---Node 9
----Node 10
--Node 5
--Node 6
-Node 3
--Node 7
</code></pre>

<p>My problem is how to do I store this result to my "CategoryItem Object". I don't have any clue do I need to use iteration for this? Specially when the node is 2 level-deep. 
I want to store it in such a like this:</p>

<pre><code>List&lt;CategoryItem&gt; items = new List&lt;CategoryItem&gt;();
</code></pre>

<p>with this I can dig every objects in the 'items' object and I can access its sub-category / child / children using the GetSubCategory() method of my class. Is this possible?</p>
