Skip to content

Commit

Permalink
Backport #169 into v3 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbeuk committed Dec 11, 2022
1 parent b30af90 commit ec72f60
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public InterceptionResult<int> SavingChanges(DbContextEventData eventData, Inter
_triggerSession.CaptureDiscoveredChanges();
_triggerSession.RaiseBeforeSaveCompletedTriggers().GetAwaiter().GetResult();
}
catch
{
// We're aborting the SaveChanges call, delist the trigger session now
DelistTriggerSession(eventData);
throw;
}
finally
{
eventData.Context.ChangeTracker.AutoDetectChangesEnabled = defaultAutoDetectChangesEnabled;
Expand Down Expand Up @@ -119,6 +125,12 @@ public async ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEven
_triggerSession.CaptureDiscoveredChanges();
await _triggerSession.RaiseBeforeSaveCompletedTriggers(cancellationToken).ConfigureAwait(false);
}
catch
{
// We're aborting the SaveChanges call, delist the trigger session now
DelistTriggerSession(eventData);
throw;
}
finally
{
eventData.Context.ChangeTracker.AutoDetectChangesEnabled = defaultAutoDetectChangesEnabled;
Expand Down

0 comments on commit ec72f60

Please sign in to comment.