-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtnsions.cs
More file actions
28 lines (23 loc) · 923 Bytes
/
Extnsions.cs
File metadata and controls
28 lines (23 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using EasyWay.Internals.DomainEvents;
using EasyWay.Internals.Entities;
using EasyWay.Internals.Repositories;
using EasyWay.Internals.Transactions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace EasyWay
{
public static class Extnsions
{
public static void AddEntityFrameworkCore<TContext>(
this IServiceCollection services,
Action<DbContextOptionsBuilder> optionsAction)
where TContext : DbContext
{
services.AddDbContextPool<TContext>(optionsAction);
services.AddScoped((Func<IServiceProvider, DbContext>)(sp => sp.GetRequiredService<TContext>()));
services.AddScoped<IEntitiesContext, EntityFrameworkEntitiesContext>();
services.AddScoped(typeof(IGenericRepository<>), typeof(GenericRepository<>));
services.AddTransactions();
}
}
}