/// <summary> /// 根据条件获取菜单 /// </summary> /// <param name="userId">用户ID</param> /// <param name="moduleId">菜单ID</param> /// <returns></returns> public IList <SysModule> GetModuleListByConn(int userId, int moduleId) { using (DBContainer db = new DBContainer()) { List <SysModule> sysModuleList = (from m in db.P_Sys_GetModuleByConn(userId, moduleId) select new SysModule { Id = m.ModuleId, ModuleName = m.ModuleName, ParentId = m.ParentId, Code = m.Code, Url = m.Url, Icon = m.Icon, Sort = m.Sort, Enable = m.Enable, Description = m.Description, IsDelete = m.IsDelete, Created = m.Created, Creator = m.Creator }).ToList(); if (sysModuleList.Count == 0 && moduleId == 0) { IList <SysModule> menus = GetModuleListByConn(userId); foreach (var menu in menus) { GetParentModuleByModuleId(menu.Id, ref sysModuleList); } } return(sysModuleList.OrderBy(p => p.Sort).ToList()); } }