내가 실수 한 위치를 제안 할 수있는 사람이 있습니까?자식 개체의 일부 속성을 사용하여 개체를 다른 개체에 매핑하는 방법
public class DataModelProduct
{
public int Id {get;set;}
public string Name {get;set;}
public string Price {get;set;};
public string Brand {get;set;}
public string Color {get;set;}
public string Dimentions {get;set;}
public string Type {get;set;}
public string Network {get;set;}
}
public class Product
{
public int Id {get;set;}
public string Name {get;set;}
public string Price {get;set;}
public Specification Spec {get;set;}
}
public class Specification
{
public string Brand {get;set;}
public string Color {get;set;}
public string Dimentions {get;set;}
public string Type {get;set;}
public string Network {get;set;}
}
AutoMapper.Mapper.CreateMap< DataModelProduct, Product>();
AutoMapper.Mapper.CreateMap< DataModelProduct, Specification>();
당신은 Product
클래스는 코어 모델 및 DataModelProduct
가정 할 수는
Product
특성이 매핑 된 데이터베이스 모델이지만 Specification
속성은 null입니다.
당신 수
그리고 당신의 매핑 초기화 코드는과 같은 런타임 코드 같은 것을해야한다 매핑 코드를 추가 하시겠습니까? –
this.DB.SingleOrDefault ("여기서 id = @ 0", productId) .MapTo (); –