public static Queue<Menu> loadMenu(int securityLevel) { Queue<Menu> ret = new Queue<Menu>(); string sQuery; sQuery = "Select * from " + DB.MenuTable + " where ParentId=0 And MinSecLevel<=" + securityLevel + " Order By Priority;"; IEnumerable<dynamic> results = DB.query(sQuery); foreach(dynamic trace in results) { Menu temp = new Menu(trace); temp.loadSubMenu(securityLevel); ret.Enqueue(temp); } return ret; }
public void loadSubMenu(int securityLevel) { string sQuery = "Select * from " + DB.MenuTable + " where ParentId=" + _id + " And MinSecLevel<=" + securityLevel + " Order By Priority;"; IEnumerable<dynamic> results = DB.query(sQuery); int subId; if (results == null || !results.Any()) { return; } foreach(dynamic menu in results) { subId = menu.Id; if (subId > _id) { Menu newSub = new Menu(menu); newSub.loadSubMenu(securityLevel); subMenu.Enqueue(newSub); } } }