Interface ICanResolveReadModelForCommand

Namespace
Cratis.Arc.Queries
Assembly
Cratis.Arc.Core.dll

Defines a provider that can resolve read models by key for a command, so a read model backed by any store — Chronicle, Entity Framework Core, or another provider — can be injected into command-scoped code.

public interface ICanResolveReadModelForCommand
Extension Methods

Remarks

A read model is injectable into command-scoped code (a CommandValidator<>, Provide(), or Handle()) because it is resolvable by the command's resolved key. The command pipeline resolves each read model dependency from DI by type, and a provider contributes a command-scoped, by-key resolver for the read model types it owns through this abstraction. Providers coexist without claiming each other's read model types — each reports only the types it can resolve through ReadModelTypes, and how strongly it claims them through Ownership.

Properties

Ownership

Gets how strongly this provider claims the read model types it reports.

ReadModelForCommandOwnership Ownership { get; }

Property Value

ReadModelForCommandOwnership

ReadModelTypes

Gets the read model types this provider can resolve by key for a command.

IEnumerable<Type> ReadModelTypes { get; }

Property Value

IEnumerable<Type>

Methods

Resolve(Type, CommandContext)

Resolves the read model of the given type for the current command context, keyed by the command's resolved key.

Task<object?> Resolve(Type readModelType, CommandContext commandContext)

Parameters

readModelType Type

The type of read model to resolve.

commandContext CommandContext

The CommandContext to resolve from.

Returns

Task<object>

The resolved read model instance, or null when no instance exists for the command's key.