automapper – 如果属性类型与同一属性名称不同,则忽略映射 – C
发布时间:2020-12-15 08:14:27 所属栏目:百科 来源:网络整理
导读:如果属性类型与同一属性名称不同,我如何忽略映射? 默认情况下,它会抛出错误. Mapper.CreateMapEntityAttribute,LeadManagementService.LeadEntityAttribute();Model = Mapper.MapEntityAttribute,LeadManagementService.LeadEntityAttribute(EntityAttribut
如果属性类型与同一属性名称不同,我如何忽略映射?
默认情况下,它会抛出错误. 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()); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |