Explain the IoC (DI) Container service lifetimes?
Explain the IoC (DI) Container service lifetimes?
In .NET Core, the IoC (Inversion of Control) container, also known as the Dependency Injection (DI) container, manages the instantiation and lifetime of services. There are three primary service lifetimes available: Transient, Scoped, and Singleton. Each of these lifetimes determines how long a service instance is maintained by the DI container and how it is reused across the application.
services.AddTransient<IMyService, MyService>();
services.AddScoped<IMyService, MyService>();
services.AddSingleton<IMyService, MyService>();
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào