我有一个过滤列表,它从MenuTable返回所有不同的id。
var _parentList = _employee.Designation.Role.MenuRoles
.Select(x => new
{
MenuParentID = x.Menu.ParentID
})
.DistinctBy(x => x.MenuParentID)
.OrderBy(x => x.MenuParentID)
.ToList();
我希望选择
menutable
中所有在_parentList
中的项目。这是我尝试过的代码,但是在
_parentList.Contains(x.Id)
处出现了错误,错误信息为:System.Generic.contains的最佳匹配有一些无效的参数。
MenuParentList = _db.Menus.Where(x => _parentList.Contains(x.Id))
.Select(x => new SMS.Models.ViewModel.DashboardVM.MenuParent
{
MenuParentID = x.Id,
MenuParentName = x.MenuName
})
.ToList()
任何帮助都将不胜感激
_parentList
不仅包含Ids
,它是一个包含不同type
的列表,你正在尝试找出其中的Ids
。 - Mrinal Kambojx.Id
的类型与_parentList
中元素的类型不同。 - M.kazem Akhgary