Entity Framework Basics
This commit is contained in:
27
ASP.Net Core/EntityFrameworkBasics/IoC/IocContainer.cs
Normal file
27
ASP.Net Core/EntityFrameworkBasics/IoC/IocContainer.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace EntityFrameworkBasics
|
||||
{
|
||||
/// <summary>
|
||||
/// A shorthand access class to get DI services with nice clean short code
|
||||
/// </summary>
|
||||
public static class IoC
|
||||
{
|
||||
/// <summary>
|
||||
/// The scoped instance of the <see cref="ApplicationDbContext"/>
|
||||
/// </summary>
|
||||
public static ApplicationDbContext ApplicationDbContext => IoCContainer.Provider.GetService<ApplicationDbContext>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The dependency injection container making use of the built in .Net Core service provider
|
||||
/// </summary>
|
||||
public static class IoCContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// The service provider for this application
|
||||
/// </summary>
|
||||
public static ServiceProvider Provider { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user