Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple mappings for the same type using AutoMapper

Tags:

c#

dto

automapper

I need help with my mapper program. i have two types (Lets 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 other method i want to take the second.

I saw that "Mapper" Class is static, so i can't use CreateMap twice.

Is this possible?

thanks.

like image 956
Matan Avatar asked Jun 05 '11 13:06

Matan


1 Answers

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

Update: see also this answer.

like image 97
M4N Avatar answered Sep 24 '22 13:09

M4N