Giter VIP home page Giter VIP logo

Comments (3)

Skyppid avatar Skyppid commented on June 1, 2024

Stumbled across this issue myself. Using BuildAdapter() does not use the injected service IMapper. If you need to access services, you always need to use IMapper.

Inject IMapper in your class or pass it as parameter, then you can use await mapper.From(source).AdaptToTypeAsync<Destination>() and it will work. Only then the MapContext has access to the services.

from mapster.

benjaminoerskov avatar benjaminoerskov commented on June 1, 2024

Thanks @Skyppid!
It seems like this is still an issue though, as the docs describe that BuildAdapter() should work equally well.

from mapster.

Skyppid avatar Skyppid commented on June 1, 2024

Thanks @Skyppid! It seems like this is still an issue though, as the docs describe that BuildAdapter() should work equally well.

My assumption is since Mapster is not exclusively for ASP.Net that the docs relate to the general usage. Accessing DI in the async after-delegate is very specific to ASP.Net though and in this case you're right. The docs should be extended to supply that information for this context.

But it only makes sense that in a general scenario where you don't have DI you'd approach it like it is stated in the docs. Took me a while to figure out as well, but I guess this was never considered during the development of Async. In general the Async extension is quite a whacky workaround. It works but I'd say it's not a beautiful implementation.

At least I'm having serious issues with it when it comes to polymorphic DTOs...

from mapster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.