Coding With Rizwan
We are custom software development company, we build app, websites, software
I got over 10 reactions on one of my posts last week! Thanks everyone for your support! π
30/01/2025
π **Dependency Injection Life Cycles in .NET π**
Unlock the power of DI with these 3 key life cycles! π‘
π΅ **Transient (π)**
**When:** Fresh instance *every* time itβs requested.
**Use case:** Stateless services (e.g., sending emails π§ or logging).
**Example:** `IEmailSenderService` β no memory of past calls!
π’ **Scoped (π)**
**When:** One instance *per request*.
**Use case:** Data handling within a single request (like DB operations πΎ).
**Example:** `DbContext` β manages a single transaction per HTTP call.
π£ **Singleton (π°)**
**When:** *One instance* for the appβs entire lifetime.
**Use case:** Expensive resources or global state (e.g., caching ποΈ).
**Example:** `ICacheService` β keeps data alive as long as the app runs!
π¬ **Which one do YOU use most often?** Letβs discuss! π
06/07/2024
The end is beginning
Click here to claim your Sponsored Listing.
Category
Contact the school
Telephone
Address
Regal Building, 69, Connaught Place, New Delhi
Delhi
110001
Opening Hours
| Monday | 9am - 5pm |
| Tuesday | 9am - 5pm |
| Wednesday | 9am - 5pm |
| Thursday | 9am - 5pm |
| Friday | 9am - 5pm |