简体   繁体   English

我可以告诉AutoMapper如何在竞争地图之间进行选择吗?

[英]Can I tell AutoMapper how to pick between competing maps?

Can AutoMapper have two mappings that are the same types, but somehow use one sometimes and the second other times? AutoMapper可以有两个相同类型的映射,但有时以某种方式使用而另一次使用吗?

Something like this is what I am thinking: 我在想这样的事情:

Mapper.CreateMap<FunkyObject, Client>().ConvertUsing(new FirstConversionType());
Mapper.CreateMap<FunkyObject, Client>().ConvertUsing(new SecondConversionType());

I would like to do the above and somehow tell automapper when I do the mapping, which one to use. 我想执行上述操作,并在执行映射时以某种方式告诉automapper,使用哪个映射。 Is that possible? 那可能吗?

Call Mapper.Reset(); 调用Mapper.Reset(); before Mapper.CreateMap<...>(...); Mapper.CreateMap<...>(...); .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM