Невозможно сравнить элементы типа App.Domain.MyComplexType. Поддерживаются только примитивные типы,
типы перечислений и типы сущностей.
У меня есть эта модель:
Код: Выделить всё
public class MyEntityType // this is an entity type on the dbContext
{
public int Id {get;set;
public MyComplexType MyComplexType {get;set;}
}
public class MyComplexType // this is a complex type
{
public decimal Property1 { get; set;}
public string Property2 { get;set;}
}
public class ViewModel
{
public int Id { get;set;}
public decimal MyComplexTypeProperty1 { get;set;}
}
Код: Выделить всё
Mapper.CreateMap(); // I rely on AutoMapper's
//convention for flattening `source.MyComplexType.Property1` to `dest.MyComplexTypeProperty1'
Код: Выделить всё
var myItem = myContext.Where(x => x.Id == id).Project().To().SingleOrDefault();
В настоящее время я обойдите эту проблему, сначала вызвав SingleOrDefault(), а затем выполнив сопоставление, это работает:
Код: Выделить всё
var myItem = Mapper.Map(myContext.Find(id));
Подробнее здесь: https://stackoverflow.com/questions/301 ... pe-complex
Мобильная версия