Class NoSnapshotStrategy
- Namespace
- Stratara.Infrastructure.EventSourcing
- Assembly
- Stratara.Infrastructure.dll
ISnapshotStrategy that never writes a snapshot — the supported way to disable snapshotting globally. Streams are always rebuilt by replaying their full event history.
public sealed class NoSnapshotStrategy : ISnapshotStrategy
- Inheritance
-
NoSnapshotStrategy
- Implements
- Inherited Members
- Extension Methods
Remarks
Register with services.AddSingleton<ISnapshotStrategy, NoSnapshotStrategy>() to
override the default VersionThresholdSnapshotStrategy. Useful for short-lived
aggregates, tests, or deployments where snapshot storage is undesirable.
Methods
ShouldSnapshot(Type, long, long)
Determines whether a snapshot should be written for the stream described by the arguments.
public bool ShouldSnapshot(Type aggregateType, long currentVersion, long lastSnapshotVersion)
Parameters
aggregateTypeTypeThe runtime aggregate type of the stream being evaluated.
currentVersionlongThe stream's highest version after the events just appended.
lastSnapshotVersionlongThe version of the most recent existing snapshot for the stream, or
0when the stream has no snapshot yet.
Returns
- bool
trueto write a fresh snapshot atcurrentVersion; otherwisefalse.