如果属性类型与同一属性名称不同,我如何忽略映射?
默认情况下,它会抛出错误.
默认情况下,它会抛出错误.
Mapper.CreateMap<EntityAttribute,LeadManagementService.LeadEntityAttribute>(); Model = Mapper.Map<EntityAttribute,LeadManagementService.LeadEntityAttribute>(EntityAttribute);
.ForMember(d=>d.Field,m=>m.Ignore());
解决方法
您应该对应该忽略的属性使用ignore:
Mapper.CreateMap<EntityAttribute,LeadManagementService.LeadEntityAttribute>() ForMember(d=>d.FieldToIgnore,m=>m.Ignore());