Class OutboxInterceptor
An EF Core SaveChangesInterceptor that, before saving changes, extracts domain events from aggregate roots and persists the configured subset as OutboxMessage records.
Inherited Members
Namespace: Chapar.Outbox.EntityFrameworkCore.Interceptors
Assembly: Chapar.Outbox.EntityFrameworkCore.dll
Syntax
public sealed class OutboxInterceptor : SaveChangesInterceptor, ISaveChangesInterceptor, IInterceptor
Constructors
| Edit this page View SourceOutboxInterceptor(IOutboxStore, IOptions<ChaparOutboxOptions>)
Initializes a new instance of the OutboxInterceptor class.
Declaration
public OutboxInterceptor(IOutboxStore outboxStore, IOptions<ChaparOutboxOptions> options)
Parameters
| Type | Name | Description |
|---|---|---|
| IOutboxStore | outboxStore | The store responsible for persisting outbox messages. |
| IOptions<ChaparOutboxOptions> | options | The outbox options. |
Methods
| Edit this page View SourceSavingChangesAsync(DbContextEventData, InterceptionResult<int>, CancellationToken)
Called at the start of
Declaration
public override ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DbContextEventData | eventData | Contextual information about the DbContext being used. |
| InterceptionResult<int> | result | Represents the current result if one exists. This value will have HasResult set to true if some previous interceptor suppressed execution by calling SuppressWithResult(TResult). This value is typically used as the return value for the implementation of this method. |
| CancellationToken | cancellationToken | A CancellationToken to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| ValueTask<InterceptionResult<int>> | If HasResult is false, the EF will continue as normal.
If HasResult is true, then EF will suppress the operation it
was about to perform and use Result instead.
An implementation of this method for any interceptor that is not attempting to change the result
is to return the |
Overrides
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | If the CancellationToken is canceled. |