AutoMapper TwoWay Mapping with same Property Name
问题 Given these two objects public class UserModel { public string Name {get;set;} public IList<RoleModel> Roles {get;set;} } public class UserViewModel { public string Name {get;set;} public IList<RoleViewModel> Roles {get;set;} // notice the ViewModel } Is this the most optimal way to do the mapping, or is AutoMapper capable of mapping Roles to Roles on its own? App Config Mapper.CreateMap<UserModel, UserViewModel>() .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles)); Mapper