Extend current automapper instance with new mapper configurations

530 views Asked by At

I am using AutoMapper 10.1.1 in my .net5 application. In the startup of the project I have configured all my maps and then created mapper from the Mapper Configuration, something like:

var config = new MapperConfiguration(cfg => {
    cfg.CreateMap<S,D>()....
});
var mapper = config.CreateMapper();

Now I want to add a mapping at runtime to the existing mapper object. I can use the mapper object created above across application. So now I want to add a new configuration to that object. Something like:

var config2 = new MapperConfiguration(cfg => {
    cfg.CreateMap<S,D>()....
});
mapper.Extend(config2);

Is there any way to do this, if no what workaround I can do?

Thanks in advance

0

There are 0 answers