Skip to content

Commit

Permalink
Try to GetEventsRecords after SaveChangesAsync.
Browse files Browse the repository at this point in the history
This problem was introduced from #21211
  • Loading branch information
maliming committed Nov 13, 2024
1 parent 9abdb8e commit 86b1404
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,8 @@ protected virtual void ApplyAbpConceptsForDeletedEntity(EntityEntry entry)
originalExtraProperties = entry.OriginalValues.GetValue<ExtraPropertyDictionary>(nameof(IHasExtraProperties.ExtraProperties));
}

//TODO: Reload will throw an exception. Check it when new EF Core versions released.
entry.Reload();

// var storeValues = entry.OriginalValues;
// entry.CurrentValues.SetValues(storeValues);
// entry.OriginalValues.SetValues(storeValues);
// entry.State = EntityState.Unchanged;

if (entry.Entity is IHasExtraProperties)
{
ObjectHelper.TrySetProperty(entry.Entity.As<IHasExtraProperties>(), x => x.ExtraProperties, () => originalExtraProperties);
Expand Down
5 changes: 3 additions & 2 deletions framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public virtual async Task CompleteAsync(CancellationToken cancellationToken = de
await UnitOfWorkEventPublisher.PublishLocalEventsAsync(
localEventsToBePublished
);
LocalEvents.AddRange(GetEventsRecords(LocalEventWithPredicates));
}

if (DistributedEvents.Any())
Expand All @@ -163,10 +162,12 @@ await UnitOfWorkEventPublisher.PublishLocalEventsAsync(
await UnitOfWorkEventPublisher.PublishDistributedEventsAsync(
distributedEventsToBePublished
);
DistributedEvents.AddRange(GetEventsRecords(DistributedEventWithPredicates));
}

await SaveChangesAsync(cancellationToken);

LocalEvents.AddRange(GetEventsRecords(LocalEventWithPredicates));
DistributedEvents.AddRange(GetEventsRecords(DistributedEventWithPredicates));
}

await CommitTransactionsAsync(cancellationToken);
Expand Down

0 comments on commit 86b1404

Please sign in to comment.