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
serializerIJsonSerializerdatabaseConnectionStringstringofflineStorageFolderstring
Properties
Serializer
public IJsonSerializer Serializer { get; }
Property Value
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
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
Returns
Count(Guid, string, bool)
Used by ChangeGrid
public int Count(Guid aggregate, string keyword, bool includeChildren)
Parameters
Returns
Count(string, IEnumerable<Guid>)
Gets count of changes for an aggregate.
public int Count(string aggregateType, IEnumerable<Guid> aggregateIdentifiers)
Parameters
aggregateTypestringaggregateIdentifiersIEnumerable<Guid>
Returns
Exists(Guid, int)
Returns true if an aggregate with a specific version exists.
public bool Exists(Guid aggregate, int version)
Parameters
Returns
Exists<T>(Guid)
Returns true if an aggregate exists.
public bool Exists<T>(Guid aggregate)
Parameters
aggregateGuid
Returns
Type Parameters
T
GetAggregateType(AggregateRoot)
public static string GetAggregateType(AggregateRoot aggregate)
Parameters
aggregateAggregateRoot
Returns
GetAggregateType(Type)
public static string GetAggregateType(Type aggregateType)
Parameters
aggregateTypeType
Returns
GetAggregates(string)
Gets all the identifiers for a specific aggregate type.
public List<Guid> GetAggregates(string aggregateType)
Parameters
aggregateTypestring
Returns
GetChange(Guid, int)
Gets a specific version of change for an aggregate.
public IChange GetChange(Guid aggregate, int version)
Parameters
Returns
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
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
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
aggregateTypestringaggregateIdentifiersIEnumerable<Guid>
Returns
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
aggregateTypestringaggregateIdentifierGuid?changeTypesIEnumerable<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
Returns
- IChange[]
GetClassAndOrganization(Guid, out string, out Guid)
public void GetClassAndOrganization(Guid aggregate, out string @class, out Guid organization)
Parameters
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
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
Returns
Insert(IChange, int)
Insert change into the stream at a specific position.
public void Insert(IChange change, int index)
Parameters
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
changeTypesIEnumerable<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
Returns
Save(AggregateRoot, IEnumerable<IChange>)
Save changes.
public void Save(AggregateRoot aggregate, IEnumerable<IChange> changes)
Parameters
aggregateAggregateRootchangesIEnumerable<IChange>
Save(IChange)
Save change.
public void Save(IChange change)
Parameters
changeIChange
Save(IEnumerable<AggregateImport>)
public void Save(IEnumerable<AggregateImport> imports)
Parameters
importsIEnumerable<AggregateImport>
Unbox(Guid, Func<Guid, AggregateRoot>)
public void Unbox(Guid aggregate, Func<Guid, AggregateRoot> creator)
Parameters
aggregateGuidcreatorFunc<Guid, AggregateRoot>