Show / Hide Table of Contents

Class EventSourceRepositoryExtensions

Useful extension methods for IEventSourceRepository.

Inheritance
Object
EventSourceRepositoryExtensions
Inherited Members
System.Object.ToString()
Object.Equals(Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
Namespace: IRM.Domain.Persistance
Assembly: IRM.dll
Syntax
public static class EventSourceRepositoryExtensions

Methods

GetById<TAggregate>(IEventSourceRepository, Guid)

Gets the latest version of an aggregate from the event store.

Declaration
public static TAggregate GetById<TAggregate>(this IEventSourceRepository repository, Guid id)
    where TAggregate : class, IAggregateRoot
Parameters
IEventSourceRepository repository

The repository to get from.

System.Guid id

The unique identifier of the aggregate.

Returns
TAggregate

An aggregate that has been rehydrated from the events in the event store.

Type Parameters
TAggregate

The type of aggregate to create and load from the events.

GetByIdAsync<TAggregate>(IAsyncEventSourceRepository, Guid, CancellationToken)

An asynchronous version of GetById<TAggregate>(IEventSourceRepository, Guid), which gets an aggregate from the event store.

Declaration
public static Task<TAggregate> GetByIdAsync<TAggregate>(this IAsyncEventSourceRepository repository, Guid id, CancellationToken cancellationToken = default(CancellationToken))
    where TAggregate : class, IAggregateRoot
Parameters
IAsyncEventSourceRepository repository

The repository to get from.

System.Guid id

The unique identifier of the aggregate.

System.Threading.CancellationToken cancellationToken

The cancellation instruction.

Returns
System.Threading.Tasks.Task<TAggregate>

An aggregate that has been rehydrated from the events in the event store.

Type Parameters
TAggregate

The type of aggregate to create and load from the events.

Save(IEventSourceRepository, IEventSourced)

Saves a single event in the event store with a new commit id and uses the AggregateMetadataProvider.

Declaration
public static void Save(this IEventSourceRepository repository, IEventSourced aggregate)
Parameters
IEventSourceRepository repository

The repository to save too.

IEventSourced aggregate

The aggregate that implements IEventSourced.

Save(IEventSourceRepository, IEventSourced, IMetadataProvider[])

Saves all events created by an aggregate in the event store with a new commit id.

Declaration
public static void Save(this IEventSourceRepository repository, IEventSourced aggregate, params IMetadataProvider[] metadataProviders)
Parameters
IEventSourceRepository repository

The repository to save too.

IEventSourced aggregate

The aggregate that implements IEventSourced.

IMetadataProvider[] metadataProviders

Zero, one or more IMetadataProvider used to get metadata that can be stored together with the events.

Save(IEventSourceRepository, IEvent)

Saves a single event in the event store with a new commit id and uses the AggregateMetadataProvider.

Declaration
public static void Save(this IEventSourceRepository repository, IEvent event)
Parameters
IEventSourceRepository repository

The repository to save too.

IEvent event

The IEvent to store in the event store.

Remarks

The AggregateMetadataProvider works with an Event too, but it is recommended that you set the StreamAttribute on the event, since you don't want the event name as a stream.

Save(IEventSourceRepository, IEvent, IMetadataProvider[])

Saves a single event in the event store with a new commit id.

Declaration
public static void Save(this IEventSourceRepository repository, IEvent event, params IMetadataProvider[] metadataProviders)
Parameters
IEventSourceRepository repository

The repository to save too.

IEvent event

The IEvent to store in the event store.

IMetadataProvider[] metadataProviders

Zero, one or more IMetadataProvider used to get metadata that can be stored together with the events.

SaveAsync(IAsyncEventSourceRepository, IEventSourced, CancellationToken)

Saves a single event in the event store with a new commit id and uses the AggregateMetadataProvider.

Declaration
public static Task SaveAsync(this IAsyncEventSourceRepository repository, IEventSourced aggregate, CancellationToken cancellationToken)
Parameters
IAsyncEventSourceRepository repository

The repository to save too.

IEventSourced aggregate

The aggregate that implements IEventSourced.

System.Threading.CancellationToken cancellationToken

The cancellation instruction.

Returns
System.Threading.Tasks.Task

A task representing the asynchronous operation.

SaveAsync(IAsyncEventSourceRepository, IEventSourced, CancellationToken, IMetadataProvider[])

An asynchronous version of Save(IEventSourceRepository, IEventSourced, IMetadataProvider[]), which saves all events created by an aggregate in the event store.

Declaration
public static Task SaveAsync(this IAsyncEventSourceRepository repository, IEventSourced aggregate, CancellationToken cancellationToken, params IMetadataProvider[] metadataProviders)
Parameters
IAsyncEventSourceRepository repository

The repository to save too.

IEventSourced aggregate

The aggregate that implements IEventSourced.

System.Threading.CancellationToken cancellationToken

The cancellation instruction.

IMetadataProvider[] metadataProviders

Zero, one or more IMetadataProvider used to get metadata that can be stored together with the events.

Returns
System.Threading.Tasks.Task

A task representing the asynchronous operation.

SaveAsync(IAsyncEventSourceRepository, IEvent, CancellationToken)

An asynchronous version of Save(IEventSourceRepository, IEvent), which saves a single event in the event store.

Declaration
public static Task SaveAsync(this IAsyncEventSourceRepository repository, IEvent event, CancellationToken cancellationToken)
Parameters
IAsyncEventSourceRepository repository

The repository to save too.

IEvent event

The IEvent to store in the event store.

System.Threading.CancellationToken cancellationToken

The cancellation instruction.

Returns
System.Threading.Tasks.Task

A task representing the asynchronous operation.

Remarks

The AggregateMetadataProvider works with an Event too, but it is recommended that you set the StreamAttribute on the event, since you don't want the event name as a stream.

SaveAsync(IAsyncEventSourceRepository, IEvent, CancellationToken, IMetadataProvider[])

An asynchronous version of Save(IEventSourceRepository, IEvent, IMetadataProvider[]), which saves a single event in the event store.

Declaration
public static Task SaveAsync(this IAsyncEventSourceRepository repository, IEvent event, CancellationToken cancellationToken, params IMetadataProvider[] metadataProviders)
Parameters
IAsyncEventSourceRepository repository

The repository to save too.

IEvent event

The IEvent to store in the event store.

System.Threading.CancellationToken cancellationToken

The cancellation instruction.

IMetadataProvider[] metadataProviders

Zero, one or more IMetadataProvider used to get metadata that can be stored together with the events.

Returns
System.Threading.Tasks.Task

A task representing the asynchronous operation.

Back to top Generated by DocFX