예제 #1
0
        public static async Task DispatchDomainEventsAsync(this IMediator mediator, MembershipDbContext context)
        {
            // Sample code from eShopOnContainers (Microsoft)

            var domainAggregates = context.ChangeTracker
                                   .Entries <AggregateRoot>()
                                   .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any());

            var domainEvents = domainAggregates
                               .SelectMany(x => x.Entity.DomainEvents)
                               .ToList();

            domainAggregates.ToList()
            .ForEach(entity => entity.Entity.DomainEvents.Clear());

            var tasks = domainEvents
                        .Select(async(domainEvent) =>
            {
                await mediator.Publish(domainEvent);
            });

            await Task.WhenAll(tasks);
        }
 public PersonAggregateTypeConfiguration(MembershipDbContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #3
0
 public GenericRepository(MembershipDbContext dbContext)
 {
     _dbContext = dbContext
                  ?? throw new ArgumentNullException(nameof(dbContext), "Contstructor parameter 'dbContext' cannot be null. EID: DA4B8A10");
 }