Table of Contents

Class ChangeStore

Namespace
InSite.Persistence
Assembly
InSite.Persistence.dll
public class ChangeStore : IChangeStore
Inheritance
ChangeStore
Implements
Inherited Members

Constructors

ChangeStore(IJsonSerializer, string, string)

public ChangeStore(IJsonSerializer serializer, string databaseConnectionString, string offlineStorageFolder)

Parameters

serializer IJsonSerializer
databaseConnectionString string
offlineStorageFolder string

Properties

Serializer

public IJsonSerializer Serializer { get; }

Property Value

IJsonSerializer

Methods

Box(Guid, bool)

Copies an aggregate to offline storage and removes it from online logs.

public void Box(Guid aggregate, bool archive = true)

Parameters

aggregate Guid
archive bool

Remarks

Someone who is a purist with regard to change sourcing will red-flag this function and say the change stream for an aggregate should never be altered or removed. However, we have two scenarios in which this is a non- negotiable business requirement. First, when a customer does not renew their contract with our business, we have a contractual obligation to remove all the customer's data from our systems. Second, we frequently run test-cases to confirm system functions are operating correctly; this data is temporary by definition, and we do not want to permanently store the change streams for test aggregates.

Count(Guid, int)

Gets count of changes for an aggregate.

public int Count(Guid aggregate, int fromVersion = -1)

Parameters

aggregate Guid
fromVersion int

Returns

int

Count(Guid, string, bool)

Used by ChangeGrid

public int Count(Guid aggregate, string keyword, bool includeChildren)

Parameters

aggregate Guid
keyword string
includeChildren bool

Returns

int

Count(string, IEnumerable<Guid>)

Gets count of changes for an aggregate.

public int Count(string aggregateType, IEnumerable<Guid> aggregateIdentifiers)

Parameters

aggregateType string
aggregateIdentifiers IEnumerable<Guid>

Returns

int

Exists(Guid, int)

Returns true if an aggregate with a specific version exists.

public bool Exists(Guid aggregate, int version)

Parameters

aggregate Guid
version int

Returns

bool

Exists<T>(Guid)

Returns true if an aggregate exists.

public bool Exists<T>(Guid aggregate)

Parameters

aggregate Guid

Returns

bool

Type Parameters

T

GetAggregateType(AggregateRoot)

public static string GetAggregateType(AggregateRoot aggregate)

Parameters

aggregate AggregateRoot

Returns

string

GetAggregateType(Type)

public static string GetAggregateType(Type aggregateType)

Parameters

aggregateType Type

Returns

string

GetAggregates(string)

Gets all the identifiers for a specific aggregate type.

public List<Guid> GetAggregates(string aggregateType)

Parameters

aggregateType string

Returns

List<Guid>

GetChange(Guid, int)

Gets a specific version of change for an aggregate.

public IChange GetChange(Guid aggregate, int version)

Parameters

aggregate Guid
version int

Returns

IChange

GetChanges(Guid, int)

Gets changes for an aggregate starting at a specific version. To get all changes use version = -1.

public IChange[] GetChanges(Guid aggregate, int fromVersion)

Parameters

aggregate Guid
fromVersion int

Returns

IChange[]

GetChanges(Guid, int, int)

Gets changes for an aggregate within a specific range of versions.

public IChange[] GetChanges(Guid aggregate, int fromVersion, int toVersion)

Parameters

aggregate Guid
fromVersion int
toVersion int

Returns

IChange[]

GetChanges(string, IEnumerable<Guid>)

Enumerate changes for all aggregates of a specific type.

public List<IChange> GetChanges(string aggregateType, IEnumerable<Guid> aggregateIdentifiers)

Parameters

aggregateType string
aggregateIdentifiers IEnumerable<Guid>

Returns

List<IChange>

GetChanges(string, Guid?, IEnumerable<string>)

Gets changes for all aggregates of a specific type.

public IChange[] GetChanges(string aggregateType, Guid? aggregateIdentifier, IEnumerable<string> changeTypes)

Parameters

aggregateType string
aggregateIdentifier Guid?
changeTypes IEnumerable<string>

Returns

IChange[]

GetChangesPaged(Guid, string, bool, int, int)

Used in ChangeGrid

public IChange[] GetChangesPaged(Guid aggregate, string keyword, bool includeChildren, int skip, int pageSize)

Parameters

aggregate Guid
keyword string
includeChildren bool
skip int
pageSize int

Returns

IChange[]

GetClassAndOrganization(Guid, out string, out Guid)

public void GetClassAndOrganization(Guid aggregate, out string @class, out Guid organization)

Parameters

aggregate Guid
class string
organization Guid

GetExpired(DateTimeOffset)

Gets all aggregates that are scheduled to expire at (or before) a specific time on a specific date.

public Guid[] GetExpired(DateTimeOffset at)

Parameters

at DateTimeOffset

Returns

Guid[]

GetSerializedChangesPaged(Guid, string, bool, int, int)

Gets serialized changes for all aggregates of a specific type.

public List<SerializedChange> GetSerializedChangesPaged(Guid aggregate, string keyword, bool includeChildren, int skip, int pageSize)

Parameters

aggregate Guid
keyword string
includeChildren bool
skip int
pageSize int

Returns

List<SerializedChange>

Insert(IChange, int)

Insert change into the stream at a specific position.

public void Insert(IChange change, int index)

Parameters

change IChange
index int

Remarks

Aggregate change streams index from starting position 1 (not 0).

RegisterObsoleteChangeTypes(IEnumerable<string>)

Allows to mark a change as an obsolete ChangeStore doesn't try to deserialize an obsolete change and returns the change as SerializedChange This is useful when a specific change is obsolete and we need either ignore it or transform to a new change

public void RegisterObsoleteChangeTypes(IEnumerable<string> changeTypes)

Parameters

changeTypes IEnumerable<string>

Rollback(Guid, int)

Performs a rollback on a specific aggregate to a specific version number. In simplest terms, this method deletes all the changes in an aggregate where the version number is greater than or equal to the input parameter.

public int Rollback(Guid aggregate, int version)

Parameters

aggregate Guid
version int

Returns

int

Save(AggregateRoot, IEnumerable<IChange>)

Save changes.

public void Save(AggregateRoot aggregate, IEnumerable<IChange> changes)

Parameters

aggregate AggregateRoot
changes IEnumerable<IChange>

Save(IChange)

Save change.

public void Save(IChange change)

Parameters

change IChange

Save(IEnumerable<AggregateImport>)

public void Save(IEnumerable<AggregateImport> imports)

Parameters

imports IEnumerable<AggregateImport>

Unbox(Guid, Func<Guid, AggregateRoot>)

public void Unbox(Guid aggregate, Func<Guid, AggregateRoot> creator)

Parameters

aggregate Guid
creator Func<Guid, AggregateRoot>