How to add AutoMapper to DI in .Net core 2.0 Console Application

后端 未结 3 961
遥遥无期
遥遥无期 2020-12-07 04:14

I try to use AutoMapper in my .Net Core 2.0 Console Application. My class looks like this:

public class AutoGetCurrency
{
    private readonly IMapper mapper         


        
3条回答
  •  眼角桃花
    2020-12-07 04:56

    You need to map a concrete class that implements IMapper. I followed Automapper documentation and it worked fine, it would be more efficient to show their documentation than writing you code there and I don't want copy / paste their sample

    http://automapper.readthedocs.io/en/latest/Dependency-injection.html

    But it would be like this: services.AddTransient();

提交回复
热议问题