Table of Contents

Interface IDispatcherDataService

Namespace
Arbiter.CommandQuery.Dispatcher
Assembly
Arbiter.CommandQuery.dll

A data service for dispatching common data requests to a data store.

public interface IDispatcherDataService

Properties

Dispatcher

Gets the dispatcher used to send requests.

IDispatcher Dispatcher { get; }

Property Value

IDispatcher

Methods

All<TModel>(string?, TimeSpan?, CancellationToken)

Gets all models of the specified type from the data store.

ValueTask<IReadOnlyCollection<TModel>> All<TModel>(string? sortField = null, TimeSpan? cacheTime = null, CancellationToken cancellationToken = default) where TModel : class

Parameters

sortField string

The field or property name to sort by

cacheTime TimeSpan?

Optional time to cache the results

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<IReadOnlyCollection<TModel>>

Awaitable task returning a list TModel

Type Parameters

TModel

The type of the model

Create<TCreateModel, TReadModel>(TCreateModel, CancellationToken)

Creates the specified createModel in the data store.

ValueTask<TReadModel?> Create<TCreateModel, TReadModel>(TCreateModel createModel, CancellationToken cancellationToken = default) where TCreateModel : class where TReadModel : class

Parameters

createModel TCreateModel

The model being created

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<TReadModel>

Awaitable task returning TReadModel

Type Parameters

TCreateModel

The type of the create model.

TReadModel

The type of the read model.

Delete<TKey, TReadModel>(TKey, CancellationToken)

Deletes the model with the specified id from the data store.

ValueTask<TReadModel?> Delete<TKey, TReadModel>(TKey id, CancellationToken cancellationToken = default) where TReadModel : class

Parameters

id TKey

The identifier to delete.

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<TReadModel>

Awaitable task returning TReadModel

Type Parameters

TKey

The type of the key.

TReadModel

The type of the read model.

GetUser(CancellationToken)

Gets the current user from the request.

ValueTask<ClaimsPrincipal?> GetUser(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<ClaimsPrincipal>

Get<TKey, TModel>(IEnumerable<TKey>, TimeSpan?, CancellationToken)

Gets a list of models for the specified identifier keys from the data store.

ValueTask<IReadOnlyCollection<TModel>> Get<TKey, TModel>(IEnumerable<TKey> ids, TimeSpan? cacheTime = null, CancellationToken cancellationToken = default) where TModel : class

Parameters

ids IEnumerable<TKey>

The identifier keys to get

cacheTime TimeSpan?

Optional time to cache the results

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<IReadOnlyCollection<TModel>>

Awaitable task returning a list TModel for the specified identifier keys

Type Parameters

TKey

The type of the key

TModel

The type of the model

Get<TKey, TModel>(TKey, TimeSpan?, CancellationToken)

Gets the model for the specified identifier key from the data store.

ValueTask<TModel?> Get<TKey, TModel>(TKey id, TimeSpan? cacheTime = null, CancellationToken cancellationToken = default) where TModel : class

Parameters

id TKey

The identifier key to get

cacheTime TimeSpan?

Optional time to cache the results

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<TModel>

Awaitable task returning the TModel for the specified identifier key

Type Parameters

TKey

The type of the key

TModel

The type of the model

Page<TModel>(EntityQuery?, CancellationToken)

Gets page of models based on the specified EntityQuery query.

ValueTask<EntityPagedResult<TModel>> Page<TModel>(EntityQuery? entityQuery = null, CancellationToken cancellationToken = default) where TModel : class

Parameters

entityQuery EntityQuery
cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<EntityPagedResult<TModel>>

Awaitable task returning a paged result for TModel

Type Parameters

TModel

The type of the model

Save<TKey, TUpdateModel, TReadModel>(TKey, TUpdateModel, CancellationToken)

Saves the specified updateModel in the data store with the specified id. If the model already exists, it will be updated; otherwise it will be created.

ValueTask<TReadModel?> Save<TKey, TUpdateModel, TReadModel>(TKey id, TUpdateModel updateModel, CancellationToken cancellationToken = default) where TUpdateModel : class where TReadModel : class

Parameters

id TKey

The identifier to apply the update to.

updateModel TUpdateModel

The update model to apply.

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<TReadModel>

Awaitable task returning TReadModel

Type Parameters

TKey

The type of the key.

TUpdateModel

The type of the update model.

TReadModel

The type of the read model.

Search<TModel>(string, EntityFilter?, CancellationToken)

Searches the data store for models based on the specified search text and optional filter. TModel must implement ISupportSearch

ValueTask<IEnumerable<TModel>> Search<TModel>(string searchText, EntityFilter? entityFilter = null, CancellationToken cancellationToken = default) where TModel : class, ISupportSearch

Parameters

searchText string

The search text to search for

entityFilter EntityFilter

Optional additional filter for search

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<IEnumerable<TModel>>

Awaitable task returning a list TModel

Type Parameters

TModel

The type of the model

Select<TModel>(EntitySelect?, TimeSpan?, CancellationToken)

Gets models based on the specified EntitySelect query from the data store.

ValueTask<IReadOnlyCollection<TModel>> Select<TModel>(EntitySelect? entitySelect = null, TimeSpan? cacheTime = null, CancellationToken cancellationToken = default) where TModel : class

Parameters

entitySelect EntitySelect
cacheTime TimeSpan?

Optional time to cache the results

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<IReadOnlyCollection<TModel>>

Awaitable task returning a list TModel

Type Parameters

TModel

The type of the model

Update<TKey, TUpdateModel, TReadModel>(TKey, TUpdateModel, CancellationToken)

Updates the specified updateModel in the data store with the specified id.

ValueTask<TReadModel?> Update<TKey, TUpdateModel, TReadModel>(TKey id, TUpdateModel updateModel, CancellationToken cancellationToken = default) where TUpdateModel : class where TReadModel : class

Parameters

id TKey

The identifier to apply the update to.

updateModel TUpdateModel

The model being updated

cancellationToken CancellationToken

The request cancellation token

Returns

ValueTask<TReadModel>

Awaitable task returning TReadModel

Type Parameters

TKey

The type of the key.

TUpdateModel

The type of the update model.

TReadModel

The type of the read model.