我想使用automapper为父对象创建单个映射,并在它的子项中重新使用它。自动映射器继承 - 重用地图
对于儿童属性,我只想映射额外的字段。
这可能吗?代码我看起来像这样
CreateCalculationMap(message); ---- This does the BASE parent mappping.
Mapper.CreateMap<QuoteMessage, CalculationGipMessage>() -- This is the child.
.Include<QuoteMessage, CalculationBase>() -- Include the parent?
.ForMember(a => a.OngoingCommission, b => b.MapFrom(c => c.OngoingASF)) - Child
.ForMember(a => a.SpecialRate, b => b.MapFrom(c => c.BlahBlah))); - Child
为什么它会告诉我父母的属性没有映射?然而,我想我把它们包含在CreateCalculationMap(message)中;其中包含
Mapper.CreateMap<QuoteMessage, CalculationBase>()()