Table of Contents

Class Service<TKey1, TKey2, TKey3, TEntity, TModel, TFilter>

Namespace
Magicalizer.Domain.Services
Assembly
Magicalizer.dll

Service of models with a composite primary key of three properties.

public class Service<TKey1, TKey2, TKey3, TEntity, TModel, TFilter> : ServiceBase<TEntity, TModel, TFilter>, IService<TKey1, TKey2, TKey3, TModel, TFilter>, IService<TModel, TFilter> where TEntity : class, IEntity, new() where TModel : class, IModel<TEntity> where TFilter : class, IFilter

Type Parameters

TKey1

Type of the first primary key property.

TKey2

Type of the second primary key property.

TKey3

Type of the third primary key property.

TEntity

Entity type.

TModel

Model type.

TFilter

Filter type.

Inheritance
ServiceBase<TEntity, TModel, TFilter>
Service<TKey1, TKey2, TKey3, TEntity, TModel, TFilter>
Implements
IService<TKey1, TKey2, TKey3, TModel, TFilter>
IService<TModel, TFilter>
Inherited Members

Constructors

Service(DbContext, IEnumerable<IQueryPrefilter<TEntity, TFilter>>?, IValidator<TModel>?)

Creates a service.

public Service(DbContext dbContext, IEnumerable<IQueryPrefilter<TEntity, TFilter>>? queryPrefilters = null, IValidator<TModel>? validator = null)

Parameters

dbContext DbContext

Database context.

queryPrefilters IEnumerable<IQueryPrefilter<TEntity, TFilter>>

Query prefilters that apply initial restrictions to queries.

validator IValidator<TModel>

Model validator.

Methods

DeleteAsync(TKey1, TKey2, TKey3, CancellationToken)

Deletes the model by the composite primary key.

public virtual Task DeleteAsync(TKey1 id1, TKey2 id2, TKey3 id3, CancellationToken cancellationToken = default)

Parameters

id1 TKey1

Value of the first primary key property.

id2 TKey2

Value of the second primary key property.

id3 TKey3

Value of the third primary key property.

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(TKey1, TKey2, TKey3, IEnumerable<IInclusion<TModel>>?, CancellationToken)

Gets the model by the composite primary key.

public virtual Task<TModel?> GetByIdAsync(TKey1 id1, TKey2 id2, TKey3 id3, IEnumerable<IInclusion<TModel>>? inclusions = null, CancellationToken cancellationToken = default)

Parameters

id1 TKey1

Value of the first primary key property.

id2 TKey2

Value of the second primary key property.

id3 TKey3

Value of the third primary key property.

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.