Design Code for Change | Dependency Injection 3 | Service lifetime in DI container of ASP.NET Core

Опубликовано: 30 Март 2026
на канале: Code with Saar
198
5

This is the 3nd part of the series to talk about dependency injections. We will dive deep to understand the lifetimes of services in DI container for ASP.NET Core.



The sample could be find on the GitHub: https://github.com/xiaomi7732/CodeWit...
Link to part 1 - Concepts: https://yo utu.be/YnBPjt2dBWk
Link to part 2 - DI in .NET Core & ASP.NET Core:    • Design Code for Change | Dependency Inject...  
Link to part 3 - Service Lifetime in DI:    • Design Code for Change | Dependency Inject...  
Link to part 4 - Anti Patterns in DI:    • Design Code for Change | Dependency Inject...  

Contents:
00:00 Intro
00:42 3 Service Lifetimes by whiteboard
01:50 3 Service Lifetimes by code example
09:21 How to pick the proper lifetime for a service
11:00 Rewrite DogReport services, make decisions on their lifetimes
15:06 Wrap up