Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Configure custom DTO mapper inside app services #9400


User avatar
0
andry3ag created

Hi Team,

We have recently downloaded the ASP.Net Core 3x with Anguylar 9.x (version 8.6). I have added some custom DTO mapping under the CustomDtoMapper.cs under the "Application" project. I was wondering if its possible for me to set mapper configuration dynamically inside the services that I create. For example based on the input parameter inside the api service, I set configuration for auto mapper. So if value is 2 I map certain attributes from source to destination. And if the value is 3 I do another mapping for source and destination attributes.

Do I have to inject "IMapper" into my application service?

Thanks


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    Automapper needs to be configured first and then mapped.

    I think the dynamic mapping you mentioned may not be easy to implement. Have you checked the automapper documentation?

    https://docs.automapper.org/en/stable/Configuration.html