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

A larger unit of encapsulation than just a class. Every transaction is scoped to a single aggregate. The lifetimes of the components of an aggregate are bounded by the lifetime of the entire aggregate. More...

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

Public Member Functions

IEnumerable< IEvent< TAuthenticationToken > > GetUncommittedChanges ()
 
virtual void MarkChangesAsCommitted ()
 
virtual void LoadFromHistory (IEnumerable< IEvent< TAuthenticationToken >> history)
 

Protected Member Functions

 AggregateRoot ()
 
virtual void ApplyChange (IEvent< TAuthenticationToken > @event)
 

Properties

Guid Id [get, protected set]
 
int Version [get, protected set]
 
- Properties inherited from Cqrs.Domain.IAggregateRoot< TAuthenticationToken >
Guid Id [get]
 
int Version [get]
 

Detailed Description

A larger unit of encapsulation than just a class. Every transaction is scoped to a single aggregate. The lifetimes of the components of an aggregate are bounded by the lifetime of the entire aggregate.

Concretely, an aggregate will handle commands, apply events, and have a state model encapsulated within it that allows it to implement the required command validation, thus upholding the invariants (business rules) of the aggregate.

Why is the use of GUID as IDs a good practice?

Because they are (reasonably) globally unique, and can be generated either by the server or by the client.