我有这个代码:
var entity = context.Entities.SingleOrDefault(x => x.Id == id);
var selectedTabs = context.EntityTabs.Select(z => new EntityTabsViewModel
{
Id = z.Id,
Name = z.Name,
IsChecked = entity.EntityTabs.Contains(z)
}).ToList();
得到了这个错误:
无法创建类型的常量值 ' ProjectDomain.Entites.GENEntityTab&#39 ;.只有原始类型或 在此上下文中支持枚举类型。
,但我随后将其更改为:
var entity = context.Entities.SingleOrDefault(x => x.Id == id);
var selectedTabs = context.EntityTabs.Select(z => new EntityTabsViewModel
{
Id = z.Id,
Name = z.Name,
IsChecked = entity.EntityTabs.Select(x => x.Id).Contains(z.Id)
}).ToList();
仍然得到同样的错误!