Table of Contents

Class CommandQueryExtensions

Namespace
Arbiter.CommandQuery
Assembly
Arbiter.CommandQuery.dll

Extension methods for adding command query services to the service collection.

public static class CommandQueryExtensions
Inheritance
CommandQueryExtensions
Inherited Members

Methods

AddCommandQuery(IServiceCollection)

Adds the command query services to the service collection.

public static IServiceCollection AddCommandQuery(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Remarks

This method registers the core command query services including the mediator, principal reader, mapper, and tenant resolver.

AddCommandValidation(IServiceCollection)

Adds command validation behavior to the service collection.

public static IServiceCollection AddCommandValidation(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Remarks

This method registers a pipeline behavior that validates commands before they are processed. It ensures that any command passed through the pipeline adheres to the defined validation rules.

AddEntityCreateBehaviors<TKey, TReadModel, TCreateModel>(IServiceCollection)

Adds the entity create behaviors to the service collection.

public static IServiceCollection AddEntityCreateBehaviors<TKey, TReadModel, TCreateModel>(this IServiceCollection services) where TCreateModel : class

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

TCreateModel

The type of the create model.

Remarks

This method conditionally registers pipeline behaviors based on the interfaces implemented by TCreateModel:

  • If TCreateModel implements IHaveTenant<TKey>, tenant-based behaviors are added.
  • If TCreateModel implements ITrackCreated, creation tracking behaviors are added.
Validation and change notification behaviors are always added. Pipeline behaviors are registered in the order they should execute.

AddEntityDeleteBehaviors<TKey, TEntity, TReadModel>(IServiceCollection)

Adds the entity delete behaviors to the service collection.

public static IServiceCollection AddEntityDeleteBehaviors<TKey, TEntity, TReadModel>(this IServiceCollection services) where TEntity : class, IHaveIdentifier<TKey>, new()

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TEntity

The type of entity being operated on.

TReadModel

The type of the read model.

Remarks

This method registers change notification behaviors for delete operations. Pipeline behaviors are registered in the order they should execute.

AddEntityHybridCache<TKey, TReadModel>(IServiceCollection)

Adds the caching query behaviors for HybridCache to the service collection.

public static IServiceCollection AddEntityHybridCache<TKey, TReadModel>(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

Remarks

This method registers hybrid cache behaviors for all standard entity query operations: identifier, identifiers, paged, select, and continuation queries.

AddEntityHybridCache<TKey, TReadModel, TCreateModel, TUpdateModel>(IServiceCollection)

Adds the caching command and query behaviors for HybridCache to the service collection.

public static IServiceCollection AddEntityHybridCache<TKey, TReadModel, TCreateModel, TUpdateModel>(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

TCreateModel

The type of the create model.

TUpdateModel

The type of the update model.

Remarks

This method registers hybrid cache behaviors for both queries and commands. Query behaviors provide caching, while command behaviors handle cache expiration.

AddEntityPatchBehaviors<TKey, TEntity, TReadModel>(IServiceCollection)

Adds the entity patch behaviors to the service collection.

public static IServiceCollection AddEntityPatchBehaviors<TKey, TEntity, TReadModel>(this IServiceCollection services) where TEntity : class, IHaveIdentifier<TKey>, new()

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TEntity

The type of entity being operated on.

TReadModel

The type of the read model.

Remarks

This method registers change notification behaviors for patch operations. Pipeline behaviors are registered in the order they should execute.

AddEntityQueryBehaviors<TKey, TReadModel>(IServiceCollection)

Adds the entity query behaviors to the service collection.

public static IServiceCollection AddEntityQueryBehaviors<TKey, TReadModel>(this IServiceCollection services) where TReadModel : class

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

Remarks

This method conditionally registers pipeline behaviors based on the interfaces implemented by TReadModel:

  • If TReadModel implements IHaveTenant<TKey>, tenant-based filtering behaviors are added.
  • If TReadModel implements ITrackDeleted, soft delete filtering behaviors are added.
Pipeline behaviors are registered in the order they should execute.

AddEntityQueryDistributedCache<TKey, TReadModel>(IServiceCollection)

Adds the caching query behaviors for IDistributedCache to the service collection.

public static IServiceCollection AddEntityQueryDistributedCache<TKey, TReadModel>(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

Remarks

This method registers distributed cache behaviors for all standard entity query operations: identifier, identifiers, paged, select, and continuation queries.

AddEntityQueryMemoryCache<TKey, TReadModel>(IServiceCollection)

Adds the caching query behaviors for IMemoryCache to the service collection.

public static IServiceCollection AddEntityQueryMemoryCache<TKey, TReadModel>(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

Remarks

This method registers memory cache behaviors for all standard entity query operations: identifier, identifiers, paged, select, and continuation queries.

AddEntityUpdateBehaviors<TKey, TReadModel, TUpdateModel>(IServiceCollection)

Adds the entity update behaviors to the service collection.

public static IServiceCollection AddEntityUpdateBehaviors<TKey, TReadModel, TUpdateModel>(this IServiceCollection services) where TUpdateModel : class

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

TUpdateModel

The type of the update model.

Remarks

This method conditionally registers pipeline behaviors based on the interfaces implemented by TUpdateModel:

  • If TUpdateModel implements IHaveTenant<TKey>, tenant-based behaviors are added.
  • If TUpdateModel implements ITrackUpdated, update tracking behaviors are added.
Validation and change notification behaviors are always added. Pipeline behaviors are registered in the order they should execute.

AddEntityUpsertBehaviors<TKey, TReadModel, TUpdateModel>(IServiceCollection)

Adds the entity upsert behaviors to the service collection.

public static IServiceCollection AddEntityUpsertBehaviors<TKey, TReadModel, TUpdateModel>(this IServiceCollection services) where TUpdateModel : class

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Type Parameters

TKey

The key type for the entity model.

TReadModel

The type of the read model.

TUpdateModel

The type of the update model.

Remarks

This method conditionally registers pipeline behaviors based on the interfaces implemented by TUpdateModel:

  • If TUpdateModel implements IHaveTenant<TKey>, tenant-based behaviors are added.
  • If TUpdateModel implements ITrackUpdated, update tracking behaviors are added.
Validation and change notification behaviors are always added. Pipeline behaviors are registered in the order they should execute.

AddRemoteDispatcher(IServiceCollection)

Adds the remote dispatcher to the service collection without HTTP client configuration.

public static IServiceCollection AddRemoteDispatcher(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Remarks

This method registers the remote dispatcher without configuring the HTTP client. The client must register the RemoteDispatcher with the correct HttpClient separately.

AddRemoteDispatcher(IServiceCollection, Action<IServiceProvider, HttpClient>)

Adds the remote dispatcher to the service collection with configuration for the HTTP client.

public static IHttpClientBuilder AddRemoteDispatcher(this IServiceCollection services, Action<IServiceProvider, HttpClient> configureClient)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

configureClient Action<IServiceProvider, HttpClient>

The action to configure the HTTP client with service provider.

Returns

IHttpClientBuilder

The IHttpClientBuilder for further configuration of the HTTP client.

Remarks

This overload allows configuration of the HTTP client using both the service provider and HTTP client instance.

AddRemoteDispatcher(IServiceCollection, Action<HttpClient>)

Adds the remote dispatcher to the service collection with configuration for the HTTP client.

public static IHttpClientBuilder AddRemoteDispatcher(this IServiceCollection services, Action<HttpClient> configureClient)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

configureClient Action<HttpClient>

The action to configure the HTTP client.

Returns

IHttpClientBuilder

The IHttpClientBuilder for further configuration of the HTTP client.

Remarks

This overload allows configuration of the HTTP client using the HTTP client instance only.

AddServerDispatcher(IServiceCollection)

Adds the server dispatcher to the service collection.

public static IServiceCollection AddServerDispatcher(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

Remarks

The server dispatcher uses the mediator pattern to dispatch commands and queries locally.