linq null parameter

Posted by kusanagi on Stack Overflow See other posts from Stack Overflow or by kusanagi
Published on 2010-04-27T22:44:17Z Indexed on 2010/04/27 23:53 UTC
Read the original article Hit count: 331

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about null