I m New with AutoMapper and have a problem I mtries to resolution.
如果我有这样的来源:
public class Membership
{
public int MembershipId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string OrganizationName { get; set; }
public List<Address> Addresses { get; set; }
}
地址类别也这样看:
public class Address
{
public int AddressId{ get; set; }
public int RefAddressTypeId { get; set; }
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public bool IsPreferredAddress { get; set; }
}
我的目的地是:
public class UserInformationModel
{
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Organization { get; set; }
public string EmailAddress { get; set; }
public PhysicalAddress BillingAddress { get; set; }
public PhysicalAddress ShippingAddress { get; set; }
}
目的地地址类别是:
public class PhysicalAddress
{
public AddressType AddressType{get; set;}
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
}
我建立了这样的地图:
Mapper.CreateMap<MinistryMattersIntegration.BusinessObjects.Entities.Cokesbury.Membership, UserInformationModel>()
.ForMember(dest => dest.Organization, opt => opt.MapFrom(src=>src.OrganizationName));
这是为了加入用户信息网站,但现在我需要找到工作地址。 不过,值得注意的是,目的地是单一账单地址和单一航运地址,而在原始模型中,所有地址都作为清单储存。 你在名单上找到航运和账单地址的方式是看重RefressTypdId和IsPnewaddress。 可能只有一个首选地址。
因此,我的问题是,你们如何获得自动申请者来做这种制图? 是否可行,或者我更不了解常规的制图法?