Multiple Mappings for the Same Type Using AutoMapper

I need help with my mapper program. I have two types (say A and B) and I want to have two different mappings. In one method, I want to use the first mapping between A and B, and in another method I want to take the second.

I saw that the "Mapper" class is static, so I cannot use CreateMap twice.

Is it possible?

thanks.

+8
c # dto automapper
source share
1 answer

Instead of using the static Mapper class, you can create different instances of the MappingEngine base classes and configuration. Then you can configure the instances differently.

Update: see also this answer .

+6
source share

All Articles