简体   繁体   中英

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?

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. Is that possible?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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