linq null parameter
- by kusanagi
how can i do the code
static string BuildMenu(List<Menu> menu, int? parentId)
{
foreach (var item in menu.Where(i => i.ParentMenu == parentId || i.ParentMenu.MenuId == parentId).ToList())
{
}
}
return BuildMenu(menuList,null);
so if parentId==null then return only records i = i.ParentMenu == null but when parentId is 0 then return records with i.ParentMenu.MenuId == parentId