Show / Hide Table of Contents

    Class DbContextEventsPublisher

    Exposes some methods to handle domain events as part of the SaveChanges transaction.

    Inheritance
    object
    DbContextEventsPublisher
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.EntityFrameworkCore
    Assembly: Silverback.Core.EFCore30.dll
    Syntax
    public class DbContextEventsPublisher

    Constructors

    | Improve this doc View source

    DbContextEventsPublisher(IPublisher, DbContext)

    Initializes a new instance of the DbContextEventsPublisher class.

    Declaration
    public DbContextEventsPublisher(IPublisher publisher, DbContext dbContext)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher to be used to publish the events to the internal bus.

    DbContext dbContext

    The DbContext to be scanned for domain events.

    | Improve this doc View source

    DbContextEventsPublisher(Func<object, IEnumerable<object>?>, Action<object>, IPublisher, DbContext)

    Initializes a new instance of the DbContextEventsPublisher class.

    Declaration
    public DbContextEventsPublisher(Func<object, IEnumerable<object>?> eventsSelector, Action<object> clearEventsAction, IPublisher publisher, DbContext dbContext)
    Parameters
    Type Name Description
    Func<object, IEnumerable<object>> eventsSelector

    The custom delegate to be used to get the events out of the entities being saved.

    Action<object> clearEventsAction

    The custom delegate to be used to clear the events from the entities after they have been published.

    IPublisher publisher

    The IPublisher to be used to publish the events to the internal bus.

    DbContext dbContext

    The DbContext to be scanned for domain events.

    Methods

    | Improve this doc View source

    ExecuteSaveTransaction(Func<int>)

    Publishes the domain events generated by the tracked entities and then executes the provided save changes procedure.

    Declaration
    public int ExecuteSaveTransaction(Func<int> saveChanges)
    Parameters
    Type Name Description
    Func<int> saveChanges

    The delegate to the original SaveChanges method.

    Returns
    Type Description
    int

    The number of entities saved to the database.

    | Improve this doc View source

    ExecuteSaveTransactionAsync(Func<Task<int>>)

    Publishes the domain events generated by the tracked entities and then executes the provided save changes procedure.

    Declaration
    public Task<int> ExecuteSaveTransactionAsync(Func<Task<int>> saveChangesAsync)
    Parameters
    Type Name Description
    Func<Task<int>> saveChangesAsync

    The delegate to the original SaveChangesAsync method.

    Returns
    Type Description
    Task<int>

    A Task<TResult> representing the asynchronous operation. The task result contains the number of entities saved to the database.

    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini