Do all mapping in one place with the new API changes?
See original GitHub issueBefore the change not to use the static API, I had just one static class with one method where I did all the mappings I needed. I called this method in Application_Start.
I also had an ‘IgnoreUnmapped’ extension which used Automapper’s static FindTypeMapFor method.
So, for example, I had:
public static void Map() { Mapper.CreateMap<CustomerModel, CustomerDto>().ReverseMap(); Mapper.CreateMap<CustomerAddressModel, CustomerAddressDto>().ReverseMap(); Mapper.CreateMap<CustomerBankModel, CustomerBankDto>().ReverseMap() .IgnoreUnmapped(); Mapper.CreateMap<CustomerCourseModel, CustomerCourseDto>().ReverseMap() .ForMember(model => model.Field1, option => option.Ignore()) .ForMember(model => model.Field2, option => option.Ignore()); }
So now where am I going to place all my mapping?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
Create a mapping profile class (derived from Profile) and override Configure() with your mappings:
Then, depending on how your app is set up, instantiate it and use it. In my case, I inject it with Ninject.
Not sure what to do about the extension. Maybe someone else can chime in.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.