Interface IQuery<TResponse>
- Namespace
- SimpleMediator
- Assembly
- SimpleMediator.dll
Represents an immutable query that produces a result.
public interface IQuery<out TResponse> : IRequest<TResponse>
Type Parameters
TResponseType produced by the handler when the query is resolved.
Examples
public sealed record GetAgendaById(Guid AgendaId) : IQuery<Option<AgendaReadModel>>;
public sealed class GetAgendaHandler : IQueryHandler<GetAgendaById, Option<AgendaReadModel>>
{
public Task<Option<AgendaReadModel>> Handle(GetAgendaById request, CancellationToken cancellationToken)
{
// Look up the record and project it to the read model.
}
}
Remarks
Queries should avoid mutating state. This pattern encourages pure responses that are easy to cache.