У меня есть 1 класс, который мне нужно сопоставить с несколькими классами, например.
Это источник, из которого я сопоставляю (модель представления):
public class UserBM
{
public int UserId { get; set; }
public string Address { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string State { get; set; }
public int CountryId { get; set; }
public string Country { get; set; }
}
Вот как выглядит целевой класс (модель предметной области):
public abstract class User
{
public int UserId { get; set; }
public virtual Location Location { get; set; }
public virtual int? LocationId { get; set; }
}
public class Location
{
public int LocationId { get; set; }
public string Address { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string State { get; set; }
public virtual int CountryId { get; set; }
public virtual Country Country { get; set; }
}
Так в настоящее время выглядит моя карта создания автомата:
Mapper.CreateMap<UserBM, User>();