Table of Contents

Class ApplicationSaveChangesInterceptor

Namespace
ReferenceApplication.Infrastructure.Data
Assembly
ReferenceApplication.Infrastructure.dll

Invokes the application save pipeline from the EF Core SaveChanges interception lifecycle.

public sealed class ApplicationSaveChangesInterceptor : SaveChangesInterceptor, ISaveChangesInterceptor, IInterceptor
Inheritance
ApplicationSaveChangesInterceptor
Implements
Inherited Members

Constructors

ApplicationSaveChangesInterceptor(IApplicationSaveChangesPipeline)

Initializes a new instance of the ApplicationSaveChangesInterceptor class.

public ApplicationSaveChangesInterceptor(IApplicationSaveChangesPipeline saveChangesPipeline)

Parameters

saveChangesPipeline IApplicationSaveChangesPipeline

The application-owned save pipeline.

Methods

SavedChanges(SaveChangesCompletedEventData, int)

Runs ApplyAfterSaveChanges(ApplicationDbContext) after EF Core persists the tracked changes of an ApplicationDbContext, and saves again when the pipeline appended audit records that depend on database-generated values.

public override int SavedChanges(SaveChangesCompletedEventData eventData, int result)

Parameters

eventData SaveChangesCompletedEventData

Contextual information about the completed save operation.

result int

The number of state entries written by the original save.

Returns

int

The result supplied by EF Core.

SavedChangesAsync(SaveChangesCompletedEventData, int, CancellationToken)

Runs ApplyAfterSaveChangesAsync(ApplicationDbContext, CancellationToken) after EF Core asynchronously persists the tracked changes of an ApplicationDbContext, and saves again when the pipeline appended audit records that depend on database-generated values.

public override ValueTask<int> SavedChangesAsync(SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default)

Parameters

eventData SaveChangesCompletedEventData

Contextual information about the completed save operation.

result int

The number of state entries written by the original save.

cancellationToken CancellationToken

A token that can cancel the operation.

Returns

ValueTask<int>

The result supplied by EF Core.

SavingChanges(DbContextEventData, InterceptionResult<int>)

Runs ApplyBeforeSaveChanges(ApplicationDbContext) before EF Core persists the tracked changes of an ApplicationDbContext. Other contexts pass through unchanged.

public override InterceptionResult<int> SavingChanges(DbContextEventData eventData, InterceptionResult<int> result)

Parameters

eventData DbContextEventData

Contextual information about the save operation.

result InterceptionResult<int>

The current interception result, returned unchanged.

Returns

InterceptionResult<int>

The result supplied by EF Core.

SavingChangesAsync(DbContextEventData, InterceptionResult<int>, CancellationToken)

Runs ApplyBeforeSaveChangesAsync(ApplicationDbContext, CancellationToken) before EF Core asynchronously persists the tracked changes of an ApplicationDbContext. Other contexts pass through unchanged.

public override ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)

Parameters

eventData DbContextEventData

Contextual information about the save operation.

result InterceptionResult<int>

The current interception result, returned unchanged.

cancellationToken CancellationToken

A token that can cancel the operation.

Returns

ValueTask<InterceptionResult<int>>

The result supplied by EF Core.