Table of Contents

Interface IService<TKey, TModel, TFilter>

Namespace
Magicalizer.Domain.Services.Abstractions
Assembly
Magicalizer.Domain.Services.Abstractions.dll

Service of models with a primary key of one property.

public interface IService<TKey, TModel, TFilter> : IService<TModel, TFilter> where TModel : class, IModel where TFilter : class, IFilter

Type Parameters

TKey

Primary key type.

TModel

Model type.

TFilter

Filter type.

Inherited Members

Methods

DeleteAsync(TKey, CancellationToken)

Deletes the model by the primary key.

Task DeleteAsync(TKey id, CancellationToken cancellationToken = default)

Parameters

id TKey

Primary key value.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task

Exceptions

ModelNotFoundException

The model doesn't exist (or isn't available through the query prefilters).

ModelInUseException

The database restricts the deletion of the model (e.g. other models reference it).

GetByIdAsync(TKey, IEnumerable<IInclusion<TModel>>?, CancellationToken)

Gets the model by the primary key.

Task<TModel?> GetByIdAsync(TKey id, IEnumerable<IInclusion<TModel>>? inclusions = null, CancellationToken cancellationToken = default)

Parameters

id TKey

Primary key value.

inclusions IEnumerable<IInclusion<TModel>>

Inclusions to apply (property paths of related models).

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<TModel>

Model, or null if it doesn't exist.