A single instance of the service is created and shared thoughout the application's lifetime.
Usage: Well-suited for services that are expensive to create or if they need to be shared across the application.
Example:
A new instance of the service is created every time it is requested.
Usage: Well-suited for lightweight or stateless services (services that don't hold any state between calls).
A single instance of the service is created per scope and reused within that scope.
Usage: Suitable for services that maintain state within the same request but don't wantto share the state between requests.
1. Singleton
A single instance of the service is created and shared thoughout the application's lifetime.
Usage: Well-suited for services that are expensive to create or if they need to be shared across the application.
Example:
2. Transient
A new instance of the service is created every time it is requested.
Usage: Well-suited for lightweight or stateless services (services that don't hold any state between calls).
Example:
3. Scoped
A single instance of the service is created per scope and reused within that scope.
Usage: Suitable for services that maintain state within the same request but don't wantto share the state between requests.
Example: