I am learning to work with DI-container correctly and cannot understand one point. I read that I cannot inject services with smaller lifetimes into services with bigger lifetimes. For example, I shouldn’t inject Scoped
services into Singleton
service. I cannot find information about the Transient
services inside the Scoped
service.
I was searching for information on Stack Overflow and in the docs but couldn’t find an answer. From my point of view, it’s a good approach because the DI container will control the creation and disposal (if needed) of Transient
services, which are created every time they are requested, aligning with the main idea of Transient
lifetime. However, I want to be sure about this because I don’t have extensive experience with the .NET platform.
1