Skip to content

Commit a678dbb

Browse files
committed
fix: domain event dispatch order
1 parent 7e43a23 commit a678dbb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Cnblogs.Architecture.Ddd.Infrastructure.EntityFramework/BaseRepository.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public IQueryable<T> GetNoTrackingQueryable<T>()
5252
public async Task<TEntity> AddAsync(TEntity entity)
5353
{
5454
await Context.AddAsync(entity);
55-
await SaveEntitiesInternalAsync(true);
55+
await SaveEntitiesInternalAsync();
5656
return entity;
5757
}
5858

@@ -61,7 +61,7 @@ public async Task<TEnumerable> AddRangeAsync<TEnumerable>(TEnumerable entities)
6161
where TEnumerable : IEnumerable<TEntity>
6262
{
6363
await Context.AddRangeAsync(entities);
64-
await SaveEntitiesInternalAsync(true);
64+
await SaveEntitiesInternalAsync();
6565
return entities;
6666
}
6767

@@ -80,22 +80,22 @@ public async Task<TEnumerable> AddRangeAsync<TEnumerable>(TEnumerable entities)
8080
/// <inheritdoc />
8181
public async Task<TEntity> UpdateAsync(TEntity entity)
8282
{
83-
await SaveEntitiesInternalAsync(true);
83+
await SaveEntitiesInternalAsync();
8484
return entity;
8585
}
8686

8787
/// <inheritdoc />
8888
public async Task<IEnumerable<TEntity>> UpdateRangeAsync(IEnumerable<TEntity> entities)
8989
{
90-
await SaveEntitiesInternalAsync(true);
90+
await SaveEntitiesInternalAsync();
9191
return entities;
9292
}
9393

9494
/// <inheritdoc />
9595
public async Task<TEntity> DeleteAsync(TEntity entity)
9696
{
9797
Context.Remove(entity);
98-
await SaveEntitiesInternalAsync(true);
98+
await SaveEntitiesInternalAsync();
9999
return entity;
100100
}
101101

@@ -130,7 +130,7 @@ public async Task<int> SaveChangesAsync(CancellationToken cancellationToken = de
130130
/// <inheritdoc />
131131
public Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default)
132132
{
133-
return SaveEntitiesInternalAsync(false, cancellationToken);
133+
return SaveEntitiesInternalAsync(true, cancellationToken);
134134
}
135135

136136
/// <summary>
@@ -145,7 +145,7 @@ protected virtual Task BeforeDispatchDomainEventAsync(List<DomainEvent> events,
145145
}
146146

147147
private async Task<bool> SaveEntitiesInternalAsync(
148-
bool dispatchDomainEventFirst,
148+
bool dispatchDomainEventFirst = false,
149149
CancellationToken cancellationToken = default)
150150
{
151151
var entities = Context.ExtractDomainEventSources();

0 commit comments

Comments
 (0)