【发布时间】:2016-06-28 14:00:30
【问题描述】:
如果属性类型与相同的属性名称不同,我如何忽略映射? 默认情况下它会抛出错误。
Mapper.CreateMap<EntityAttribute, LeadManagementService.LeadEntityAttribute>();
Model = Mapper.Map<EntityAttribute, LeadManagementService.LeadEntityAttribute>(EntityAttribute);
我知道一种指定要忽略的属性名称的方法,但这不是我想要的。
.ForMember(d=>d.Field, m=>m.Ignore());
因为将来我可能会添加新的属性。所以我需要忽略所有具有不同数据类型的属性的映射。
【问题讨论】:
-
你试过了吗.ForAllMembers(opt => opt.Condition(IsValidType)));请参阅我的答案以获取示例源代码。
标签: c# .net automapper