LINQ to Entities无法识别方法'System.String ToString()'方法。
List <MenuModels> _menus =
_entity.SubMenus
.Where(x => x.RoleId.Split(',').ToString() == _loginCredentials.UserRoleId)
.Select(x => new MenuModels
{
MainMenuId = x.MainMenu.Id,
MainMenuName = x.MainMenu.MainMenu1,
SubMenuId = x.Id,
SubMenuName = x.SubMenu1,
ControllerName = x.Controller,
ActionName = x.Action,
RoleId = x.RoleId,
RoleName=x.Role.Roles
}).ToList();
答案 0 :(得分:1)
也许您想获得RoleId包含UserRoleId的所有子菜单。在这种情况下,您必须使用:
List<MenuModels> _menus = _entity.SubMenus.Where(x => x.RoleId.Contains(_loginCredentials.UserRoleId)).Select ...