0
현재 내가지도하는 데 필요한 다음과 같은 개체가자동 매핑하는 것은 표에 가입하세요 제거하려면
OBJECT 나는 다음과 같은 객체
OBJECT 2
에 매핑하는 것을 시도하고있다 1public class ContactInfo
{
public int ContactInfoId { get; set; }
public ICollection<PhoneToCustomer> Phones { get; set; }
}
public class PhoneToCustomer
{
public int ContactInformationId { get; set; }
public Phone Phone { get; set; }
public int PhoneId { get; set; }
}
public class Phone
{
public int PhoneId { get; set; }
public long Number { get; set; }
public PhoneType Type { get; set; }
public string Extension { get; set; }
public string CountryCode { get; set; }
public PhoneRestrictions Restrictions { get; set; }
public bool Primary { get; set; }
}
public class ContactInfoModel
{
public int ContactInfoId { get; set; }
public ICollection<PhoneModel> Phones { get; set; }
}
public class PhoneModel
{
public int PhoneId { get; set; }
public long Number { get; set; }
public PhoneType Type { get; set; }
public string Extension { get; set; }
public string CountryCode { get; set; }
public PhoneRestrictions Restrictions { get; set; }
public bool Primary { get; set; }
}
기본적으로 PhoneToCustomer 객체를 매핑 할 때 제거하려고합니다. 당신이 반대를 매핑 할 경우
AutoMapper.Mapper.CreateMap<Phone, PhoneModel>();
AutoMapper.Mapper.CreateMap<ContactInfo, ContactInfoModel>()
.ForMember(x => x.Phones, y => y.MapFrom(z => z.Phones.Select(q => q.Phone)));
: 나는 다음과 같은 매핑을 추가 할 필요가 ContactInfoModel하는 CONTACTINFO을지도하기 위해 ContactInfo.PhoneToCustomer.Phone에