我有一个类,我需要t映射到多个类,例如.
这是我从(查看模型)映射的源:
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; } }
这是我的automapper创建地图当前的样子:
Mapper.CreateMap<UserBM,User>();