I want to create static implementation of AutoMapper without dependency injection. I'm using ASP.NET CORE 2.2 and AutoMapper 9. I've found similar topic:
How to use AutoMapper 9.0.0 in Asp.Net Web Api 2 without dependency injection?
Is there any simpler way to create static implementation without DI?
You can simply build a mapper from the mapper configuration. An example is provided in the AutoMapper docs, which I have reproduced here:
Then you could simply set a
staticfield/property somewhere in your project to holdmapper.