Skip to main content
Table of Contents

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

aggregateType Type

The runtime aggregate type of the stream being evaluated.

currentVersion long

The stream's highest version after the events just appended.

lastSnapshotVersion long

The version of the most recent existing snapshot for the stream, or 0 when the stream has no snapshot yet.

Returns

bool

true to write a fresh snapshot at currentVersion; otherwise false.