public ActionResult Edit(int id)//arid角色id { AdminRole role = _adminRoleService.GetByCondition(new DirectSpecification <AdminRole>(ar => ar.ARID == id)); IEnumerable <AdminRole_Module> listarm = _adminRole_ModuleService.GetMany(new DirectSpecification <AdminRole_Module>(arm => arm.ARID == id)); var modules = _adminModuleService.GetAll().OrderBy(c => c.SortFlag).ToList(); ViewBag.Modules = modules; var ids = listarm.Select(x => x.AMID); ViewBag.ModulesCheck = modules.Where(x => ids.Contains(x.AMID)).ToList(); return(View(role)); }