-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtnsions.cs
More file actions
29 lines (24 loc) · 1.01 KB
/
Extnsions.cs
File metadata and controls
29 lines (24 loc) · 1.01 KB
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
29
using EasyWay.Internals.AggregateRoots;
using EasyWay.Internals.DomainEvents;
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<IAggregateRootsContext, EntityFrameworkAggregateRootsContext>();
services.AddTransient<IDomainEventsContext, DomainEventsAccessor>();
services.AddScoped(typeof(IWriteGenericRepository<>), typeof(WriteGenericRepository<>));
services.AddTransactions();
}
}
}