CQRS.NET  2.2
A lightweight enterprise framework to write CQRS, event-sourced and micro-service applications in hybrid multi-datacentre, on-premise and Azure environments.
Cqrs.Domain.AggregateRepository< TAuthenticationToken > Class Template Reference

Provides basic repository methods for operations with instances of IAggregateRoot<TAuthenticationToken> using an IEventStore<TAuthenticationToken> that also publishes events once saved. More...

+ Inheritance diagram for Cqrs.Domain.AggregateRepository< TAuthenticationToken >:

Public Member Functions

 AggregateRepository (IAggregateFactory aggregateFactory, IEventStore< TAuthenticationToken > eventStore, IEventPublisher< TAuthenticationToken > publisher, ICorrelationIdHelper correlationIdHelper, IConfigurationManager configurationManager)
 Instantiates a new instance of AggregateRepository<TAuthenticationToken> More...
 
virtual void Save< TAggregateRoot > (TAggregateRoot aggregate, int? expectedVersion=null)
 Save and persist the provided aggregate , optionally providing the version number the IAggregateRoot<TAuthenticationToken> is expected to be at. More...
 
virtual TAggregateRoot Get< TAggregateRoot > (Guid aggregateId, IList< IEvent< TAuthenticationToken >> events=null)
 Retrieves an IAggregateRoot<TAuthenticationToken> of type TAggregateRoot . More...
 
virtual TAggregateRoot GetToVersion< TAggregateRoot > (Guid aggregateId, int version, IList< IEvent< TAuthenticationToken >> events=null)
 Retrieves an IAggregateRoot<TAuthenticationToken> of type TAggregateRoot up to and including the provided version . More...
 
virtual TAggregateRoot GetToDate< TAggregateRoot > (Guid aggregateId, DateTime versionedDate, IList< IEvent< TAuthenticationToken >> events=null)
 Retrieves an IAggregateRoot<TAuthenticationToken> of type TAggregateRoot up to and including the provided versionedDate . More...
 
virtual void LoadAggregateHistory< TAggregateRoot > (TAggregateRoot aggregate, IList< IEvent< TAuthenticationToken >> events=null, bool throwExceptionOnNoEvents=true)
 If events is null, loads the events from EventStore, checks for duplicates and then rehydrates the aggregate with the events. More...
 
virtual void LoadAggregateHistoryToVersion< TAggregateRoot > (TAggregateRoot aggregate, int version, IList< IEvent< TAuthenticationToken >> events=null, bool throwExceptionOnNoEvents=true)
 If events is null, loads the events from EventStore, checks for duplicates and then rehydrates the aggregate with the events. More...
 
virtual void LoadAggregateHistoryToDate< TAggregateRoot > (TAggregateRoot aggregate, DateTime versionedDate, IList< IEvent< TAuthenticationToken >> events=null, bool throwExceptionOnNoEvents=true)
 If events is null, loads the events from EventStore, checks for duplicates and then rehydrates the aggregate with the events. More...
 

Protected Member Functions

virtual void PublishEvent (IEvent< TAuthenticationToken > @event)
 Publish the saved event . More...
 
virtual TAggregateRoot CreateAggregate< TAggregateRoot > (Guid id)
 Calls IAggregateFactory.Create to get a, TAggregateRoot . More...
 
virtual TAggregateRoot LoadAggregate< TAggregateRoot > (Guid id, IList< IEvent< TAuthenticationToken >> events=null)
 Calls IAggregateFactory.Create to get a, TAggregateRoot and then calls LoadAggregateHistory<TAggregateRoot>. More...
 
virtual TAggregateRoot LoadAggregateToVersion< TAggregateRoot > (Guid id, int version, IList< IEvent< TAuthenticationToken >> events=null)
 Calls IAggregateFactory.Create to get a, TAggregateRoot and then calls LoadAggregateHistory<TAggregateRoot>. More...
 
virtual TAggregateRoot LoadAggregateToDate< TAggregateRoot > (Guid id, DateTime versionedDate, IList< IEvent< TAuthenticationToken >> events=null)
 Calls IAggregateFactory.Create to get a, TAggregateRoot and then calls LoadAggregateHistory<TAggregateRoot>. More...
 

Properties

IEventStore< TAuthenticationToken > EventStore [get]
 Gets or sets the IEventStore<TAuthenticationToken> used to store and retrieve events from. More...
 
IEventPublisher< TAuthenticationToken > Publisher [get]
 Gets or sets the Publisher used to publish events on once saved into the EventStore. More...
 
IAggregateFactory AggregateFactory [get]
 Gets or set the IAggregateFactory. More...
 
ICorrelationIdHelper CorrelationIdHelper [get]
 Gets or set the ICorrelationIdHelper. More...
 
IConfigurationManager ConfigurationManager [get]
 Gets or sets the IConfigurationManager. More...
 

Detailed Description

Provides basic repository methods for operations with instances of IAggregateRoot<TAuthenticationToken> using an IEventStore<TAuthenticationToken> that also publishes events once saved.

Template Parameters
TAuthenticationTokenThe Type of authentication token.