Completely changes way of fetching context

This commit is contained in:
2020-01-22 22:09:07 +01:00
parent f28ea09235
commit cc8eb0302e
5 changed files with 69 additions and 35 deletions

View 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; }
}
}