Table of Contents

Interface IReadModels

Namespace
Cratis.Chronicle.ReadModels
Assembly
Cratis.Chronicle.dll

Defines a system that works with read models in the system.

public interface IReadModels

Methods

DehydrateSession(ReadModelSessionId, Type, ReadModelKey)

Dehydrate a session.

Task DehydrateSession(ReadModelSessionId sessionId, Type readModelType, ReadModelKey readModelKey)

Parameters

sessionId ReadModelSessionId

The ReadModelSessionId to dehydrate.

readModelType Type

Type of read model.

readModelKey ReadModelKey

ReadModelKey to dehydrate for.

Returns

Task

Awaitable task.

GetInstanceById(Type, ReadModelKey, ReadModelSessionId?)

Get a read model instance by its key.

Task<object> GetInstanceById(Type readModelType, ReadModelKey key, ReadModelSessionId? sessionId = null)

Parameters

readModelType Type

The read model type.

key ReadModelKey

The ReadModelKey to get instance for.

sessionId ReadModelSessionId

Optional ReadModelSessionId to get for a specific session.

Returns

Task<object>

The read model instance.

GetInstanceById<TReadModel>(ReadModelKey, ReadModelSessionId?)

Get a read model instance by its key.

Task<TReadModel> GetInstanceById<TReadModel>(ReadModelKey key, ReadModelSessionId? sessionId = null)

Parameters

key ReadModelKey

The ReadModelKey to get instance for.

sessionId ReadModelSessionId

Optional ReadModelSessionId to get for a specific session.

Returns

Task<TReadModel>

The read model instance.

Type Parameters

TReadModel

The read model type.

GetInstances<TReadModel>(EventCount?)

Get all instances of a read model by applying all events.

Task<IEnumerable<TReadModel>> GetInstances<TReadModel>(EventCount? eventCount = null)

Parameters

eventCount EventCount

Optional maximum number of events to process. Defaults to Unlimited.

Returns

Task<IEnumerable<TReadModel>>

Collection of read model instances.

Type Parameters

TReadModel

The read model type.

GetSnapshotsById<TReadModel>(ReadModelKey)

Get snapshots of a read model grouped by CorrelationId by walking through events from the beginning.

Task<IEnumerable<ReadModelSnapshot<TReadModel>>> GetSnapshotsById<TReadModel>(ReadModelKey readModelKey)

Parameters

readModelKey ReadModelKey

ReadModelKey to get snapshots for.

Returns

Task<IEnumerable<ReadModelSnapshot<TReadModel>>>

Collection of ReadModelSnapshot<TReadModel>.

Type Parameters

TReadModel

Type of read model.

Register()

Register the read models in the system.

Task Register()

Returns

Task

An awaitable task.

Register<TReadModel>()

Register a specific read model type.

Task Register<TReadModel>()

Returns

Task

An awaitable task.

Type Parameters

TReadModel

The type of the read model to register.

Watch<TReadModel>()

Observe changes for a specific read model.

IObservable<ReadModelChangeset<TReadModel>> Watch<TReadModel>()

Returns

IObservable<ReadModelChangeset<TReadModel>>

An observable of ReadModelChangeset<TReadModel>.

Type Parameters

TReadModel

Type of read model to observe changes for.