public static IList<MenuInfo> GetMenus() { IList<MenuInfo> list = new List<MenuInfo>(); MenuDao dao = new MenuDao(); IList<MenuInfo> topMenus = dao.GetTopMenus(); if (topMenus != null) { foreach (MenuInfo info in topMenus) { list.Add(info); IList<MenuInfo> menusByParentId = dao.GetMenusByParentId(info.MenuId); if (menusByParentId != null) { foreach (MenuInfo info2 in menusByParentId) { list.Add(info2); } } } } return list; }
public static IList<MenuInfo> GetInitMenus() { MenuDao dao = new MenuDao(); IList<MenuInfo> topMenus = dao.GetTopMenus(); foreach (MenuInfo info in topMenus) { info.Chilren = dao.GetMenusByParentId(info.MenuId); if (info.Chilren == null) { info.Chilren = new List<MenuInfo>(); } } return topMenus; }