public List<AppInfo> GetTotalAppsInfo()
{
Action<classname> SetChildren = null;
//Initialize the hierarchical list to root level items
List<classname> hierarchicalItems = all
.Where(rootItem => rootItem.ParentId == 0)
.ToList();
SetChildren = parent =>
{
parent.ChildItems = all
.Where(childItem => childItem.ParentId == parent.Id)
.ToList();
//Recursively call the SetChildren method for each child.
parent.ChildItems
.ForEach(SetChildren);
};
//Call the SetChildren method to set the children on each root level item.
hierarchicalItems.ForEach(SetChildren);
return hierarchicalItems;
}
No comments:
Post a Comment