Skip to content

Demonstrations, Tests, and Examples of Dependency Injection Lifetimes in .NET Core

License

Notifications You must be signed in to change notification settings

justinjstark/DependencyInjectionLifetimes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dependency Injection Lifetimes

Demonstrations, Tests, and Examples of Dependency Injection Lifetimes in .NET

Parts

Want to learn about transient, scoped, and singleton lifetimes? Start here.

Simple tests demonstrating transient, scoped, and singleton lifetimes. If you are new to dependency injection lifetimes, these tests provide simple use cases to build an understanding.

A list of best practices including

  • When to use AddDbContext vs AddDbContextPool
  • How to properly use HttpClient
  • How to use scopes within services

A console application that runs a job every five seconds. This example demonstrates how to use scopes to properly handle Entity Framework's DbContext and other dependencies where lifetime consideration is important.

A Quartz.NET IJobFactory that creates a lifetime scope for each job.

About

Demonstrations, Tests, and Examples of Dependency Injection Lifetimes in .NET Core

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages