Completely changes way of fetching context
This commit is contained in:
26
ASP.Net Core/MVCBasics/IoC/IocContainer.cs
Normal file
26
ASP.Net Core/MVCBasics/IoC/IocContainer.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EntityFrameworkBasics
|
||||
{
|
||||
/// <summary>
|
||||
/// A shorthand access class to get DI services with nice clean short code
|
||||
/// </summary>
|
||||
public static class IoC
|
||||
{
|
||||
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