我想我理解以下错误,但不确定如何解决,
“ Classname”:“ System.NotSupportedException”,“ Message”:“实体或 复杂类型'Childaccessory'不能在LINQ中构造为 实体查询。”,
我应该创建一个DTO并将其从存储库中返回以解决该问题,还是有更好的解决方法?
我正在尝试获取儿童配件,但还包括父表中的默认配件。
public class ChildaccessoryRepository: IChildaccessoryRepository {
private readonly EquipmentContext _context;
public DirectoryEquipmentRepository(EquipmentContext context) {
_context = context;
}
public IEnumerable < Childaccessory > getchildaccessories(Guid clientReference) {
var accessories = from a in _context.accessory
join ca in _context.Childaccessory
on new {
accessoryId = a.Id,ClientReference = clientReference
}
equals new {
ca.accessoryId,ca.ClientReference
}
into ca_join
from ca in ca_join.DefaultIfEmpty()
where
ca.Isactive == true ||
ca.Isactive == null
//select ca;
select new Childaccessory
{
accessoryId = ca.accessoryId,SomeOtherColumn = ca.SomeOtherColumn,accessory = ca.accessory,});
}
}