Class EfCoreTracedAggregateRepository<TEntity, TKey>
- Namespace
- Savvyio.Extensions.EFCore.Domain.EventSourcing
- Assembly
- Savvyio.Extensions.EFCore.Domain.EventSourcing.dll
Provides an implementation of the EfCoreRepository<TEntity, TKey> that is optimized for Domain Driven Design and Event Sourcing.
public class EfCoreTracedAggregateRepository<TEntity, TKey> : ITracedAggregateRepository<TEntity, TKey>, IReadableRepository<TEntity, TKey>, IWritableRepository<TEntity, TKey>, IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey>, ITracedAggregateRoot<TKey>
Type Parameters
TEntityThe type of the entity that implements the ITracedAggregateRoot<TKey> interface.
TKeyThe type of the key that uniquely identifies the entity.
- Inheritance
-
EfCoreTracedAggregateRepository<TEntity, TKey>
- Implements
-
ITracedAggregateRepository<TEntity, TKey>IReadableRepository<TEntity, TKey>IWritableRepository<TEntity, TKey>IRepository<TEntity, TKey>
- Derived
Constructors
EfCoreTracedAggregateRepository(IEfCoreDataSource, IMarshaller)
Initializes a new instance of the EfCoreTracedAggregateRepository<TEntity, TKey> class.
public EfCoreTracedAggregateRepository(IEfCoreDataSource source, IMarshaller marshaller)
Parameters
sourceIEfCoreDataSourceThe IEfCoreDataSource that handles actual I/O communication with a source of data.
marshallerIMarshallerThe IMarshaller that is used when converting between ITracedDomainEvent and arbitrary data.
Methods
Add(TEntity)
Marks the specified entity to be added in the data store when SaveChangesAsync(Action<AsyncOptions>) is called.
public void Add(TEntity entity)
Parameters
entityTEntityThe aggregate to add.
AddRange(IEnumerable<TEntity>)
Marks the specified entities to be added in the data store when SaveChangesAsync(Action<AsyncOptions>) is called.
public void AddRange(IEnumerable<TEntity> entities)
Parameters
entitiesIEnumerable<TEntity>The aggregates to add.
GetByIdAsync(TKey, Action<AsyncOptions>)
Loads an aggregate from the specified id asynchronous.
public Task<TEntity> GetByIdAsync(TKey id, Action<AsyncOptions> setup = null)
Parameters
idTKeyThe key that uniquely identifies the aggregate.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
- Task<TEntity>
A Task<TResult> that represents the asynchronous operation. The task result either contains the entity of the operation or
nullif not found.
Exceptions
- MissingMethodException
TEntitydoes not have a suitable constructor.