Topic:   dependency injection .net core.
Mar 30, 2021 11:42 1 Replies 862 Views KRISHNA SWAROOP

What is dependency injection .net core? Can someone explain it by taking simple real-life based examples? I have checked it out on internet, but it's explained in very complex way everywhere.

Prev Next
Topic Replies (1)
  1. 1
    idnkx user


    Dependency Injection is a software design pattern where dependencies are not created by the client, but rather passed to the client.
    Instead of creating dependencies by new keyword, we will define what we need. We delegate the responsibility of passing those to the injector. Class does not need to know how to create dependency and it’s not a part of its logic.
    With a separation of creation and behavior of our service we can build loosely coupled services. In our classes, we concentrate on how it’s going to behave.
    Example -
    Let’s say we have a Web API for getting events. We have EventsController, that gets events from EventsProvider and it gets movie ratings from MovieRatingProvider. On the schema it will look like this:

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.

Let`s Connect