From a678dbbeba55c97b92e63f19b7b5ccb1804af97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=98=9F=E7=B9=81?= Date: Thu, 9 Feb 2023 10:01:41 +0800 Subject: [PATCH] fix: domain event dispatch order --- .../BaseRepository.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Cnblogs.Architecture.Ddd.Infrastructure.EntityFramework/BaseRepository.cs b/src/Cnblogs.Architecture.Ddd.Infrastructure.EntityFramework/BaseRepository.cs index 8d5ac22..d73f816 100644 --- a/src/Cnblogs.Architecture.Ddd.Infrastructure.EntityFramework/BaseRepository.cs +++ b/src/Cnblogs.Architecture.Ddd.Infrastructure.EntityFramework/BaseRepository.cs @@ -52,7 +52,7 @@ public IQueryable GetNoTrackingQueryable() public async Task AddAsync(TEntity entity) { await Context.AddAsync(entity); - await SaveEntitiesInternalAsync(true); + await SaveEntitiesInternalAsync(); return entity; } @@ -61,7 +61,7 @@ public async Task AddRangeAsync(TEnumerable entities) where TEnumerable : IEnumerable { await Context.AddRangeAsync(entities); - await SaveEntitiesInternalAsync(true); + await SaveEntitiesInternalAsync(); return entities; } @@ -80,14 +80,14 @@ public async Task AddRangeAsync(TEnumerable entities) /// public async Task UpdateAsync(TEntity entity) { - await SaveEntitiesInternalAsync(true); + await SaveEntitiesInternalAsync(); return entity; } /// public async Task> UpdateRangeAsync(IEnumerable entities) { - await SaveEntitiesInternalAsync(true); + await SaveEntitiesInternalAsync(); return entities; } @@ -95,7 +95,7 @@ public async Task> UpdateRangeAsync(IEnumerable en public async Task DeleteAsync(TEntity entity) { Context.Remove(entity); - await SaveEntitiesInternalAsync(true); + await SaveEntitiesInternalAsync(); return entity; } @@ -130,7 +130,7 @@ public async Task SaveChangesAsync(CancellationToken cancellationToken = de /// public Task SaveEntitiesAsync(CancellationToken cancellationToken = default) { - return SaveEntitiesInternalAsync(false, cancellationToken); + return SaveEntitiesInternalAsync(true, cancellationToken); } /// @@ -145,7 +145,7 @@ protected virtual Task BeforeDispatchDomainEventAsync(List events, } private async Task SaveEntitiesInternalAsync( - bool dispatchDomainEventFirst, + bool dispatchDomainEventFirst = false, CancellationToken cancellationToken = default) { var entities = Context.ExtractDomainEventSources();