My table
EmpID Name ReportsTo
1 Accounts 0
2 Branches 0
3 Loans 1
4 Incomes 2
Accounts, branches are parents loans incomes their childs
what is the query to return Accounts with childs
@helper GetTreeView(List siteMenu, int parentID)
{
foreach (var i in siteMenu.Where(a => a.ReportsTo.Equals(parentID)))
{
@{var submenu = siteMenu.Where(a => a.ReportsTo.Equals(i.EmpID)).Count();}
@if (submenu > 0)
{
}
else
{
}
@*@i.Name*@
@if (submenu > 0)
{
@Treeview.GetTreeView(siteMenu, i.EmpID)
@* Recursive Call for Populate Sub items here*@
}
}
}
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 7, 2016, 9:29 PM EDT
Posted Jul 7, 2016, 9:59 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Jul 7, 2016, 11:08 PM EDT