Table of Contents

Interface IAsyncReadRepository<TEntity, TKey>

Namespace
eQuantic.Core.Data.Repository.Read
Assembly
eQuantic.Core.Data.dll

The asynchronous read repository. Query shaping (filtering, sorting, includes, tracking) is expressed through a single QueryOptions<TEntity> argument, and paged reads return a PagedResult<T>.

public interface IAsyncReadRepository<TEntity, TKey> : IAsyncRepository, IRepository, IDisposable where TEntity : class, IEntity<TKey>

Type Parameters

TEntity

The type of the entity.

TKey

The type of the key.

Inherited Members

Methods

AllAsync(Expression<Func<TEntity, bool>>, QueryOptions<TEntity>?, CancellationToken)

Determines whether all elements matching the supplied options satisfy the predicate.

Task<bool> AllAsync(Expression<Func<TEntity, bool>> predicate, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

predicate Expression<Func<TEntity, bool>>

The predicate that every element must satisfy.

options QueryOptions<TEntity>

Optional query shaping, including a scope filter to apply first.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true when every matching element satisfies the predicate; otherwise false.

AllMatchingAsync(ISpecification<TEntity>, QueryOptions<TEntity>?, CancellationToken)

Gets all elements matching the supplied specification.

Task<IEnumerable<TEntity>> AllMatchingAsync(ISpecification<TEntity> specification, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

specification ISpecification<TEntity>

The specification to apply.

options QueryOptions<TEntity>

Optional additional query shaping.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IEnumerable<TEntity>>

The matching entities.

AnyAsync(QueryOptions<TEntity>?, CancellationToken)

Determines whether any element matches the supplied options.

Task<bool> AnyAsync(QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true when at least one element matches; otherwise false.

CountAsync(QueryOptions<TEntity>?, CancellationToken)

Counts the elements matching the supplied options.

Task<long> CountAsync(QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long>

The number of matching elements.

GetAllAsync(QueryOptions<TEntity>?, CancellationToken)

Gets all elements, optionally shaped by options.

Task<IEnumerable<TEntity>> GetAllAsync(QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

options QueryOptions<TEntity>

Optional query shaping (filter, sorting, includes, tracking).

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IEnumerable<TEntity>>

The matching entities.

GetAsync(TKey, QueryOptions<TEntity>?, CancellationToken)

Gets the element identified by its key.

Task<TEntity?> GetAsync(TKey id, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

id TKey

The entity key.

options QueryOptions<TEntity>

Optional query shaping.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TEntity>

The entity, or null when not found.

GetFilteredAsync(Expression<Func<TEntity, bool>>, QueryOptions<TEntity>?, CancellationToken)

Gets all elements matching the supplied predicate.

Task<IEnumerable<TEntity>> GetFilteredAsync(Expression<Func<TEntity, bool>> filter, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

filter Expression<Func<TEntity, bool>>

The predicate to apply.

options QueryOptions<TEntity>

Optional additional query shaping.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IEnumerable<TEntity>>

The matching entities.

GetFirstAsync(QueryOptions<TEntity>, CancellationToken)

Gets the first element matching the supplied options, or null when none match.

Task<TEntity?> GetFirstAsync(QueryOptions<TEntity> options, CancellationToken cancellationToken = default)

Parameters

options QueryOptions<TEntity>

The query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TEntity>

The first matching entity, or null.

GetFirstMappedAsync<TResult>(Expression<Func<TEntity, TResult>>, QueryOptions<TEntity>, CancellationToken)

Gets the first element matching the supplied options, projected to TResult.

Task<TResult?> GetFirstMappedAsync<TResult>(Expression<Func<TEntity, TResult>> map, QueryOptions<TEntity> options, CancellationToken cancellationToken = default)

Parameters

map Expression<Func<TEntity, TResult>>

The projection to apply.

options QueryOptions<TEntity>

The query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TResult>

The first projected result, or the default when none match.

Type Parameters

TResult

The projection result type.

GetMappedAsync<TResult>(Expression<Func<TEntity, TResult>>, QueryOptions<TEntity>?, CancellationToken)

Gets all elements projected to TResult.

Task<IEnumerable<TResult>> GetMappedAsync<TResult>(Expression<Func<TEntity, TResult>> map, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

map Expression<Func<TEntity, TResult>>

The projection to apply.

options QueryOptions<TEntity>

Optional query shaping (filter, sorting, includes, tracking).

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IEnumerable<TResult>>

The projected results.

Type Parameters

TResult

The projection result type.

GetPagedAsync(PageRequest, QueryOptions<TEntity>?, CancellationToken)

Gets a page of elements together with the total number of matching items.

Task<PagedResult<TEntity>> GetPagedAsync(PageRequest page, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

page PageRequest

The page to retrieve.

options QueryOptions<TEntity>

Optional query shaping (filter, sorting, includes, tracking).

cancellationToken CancellationToken

The cancellation token.

Returns

Task<PagedResult<TEntity>>

The requested page of entities.

GetPagedAsync<TResult>(PageRequest, Expression<Func<TEntity, TResult>>, QueryOptions<TEntity>?, CancellationToken)

Gets a page of elements projected to TResult together with the total number of matching items.

Task<PagedResult<TResult>> GetPagedAsync<TResult>(PageRequest page, Expression<Func<TEntity, TResult>> map, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

page PageRequest

The page to retrieve.

map Expression<Func<TEntity, TResult>>

The projection to apply.

options QueryOptions<TEntity>

Optional query shaping (filter, sorting, includes, tracking).

cancellationToken CancellationToken

The cancellation token.

Returns

Task<PagedResult<TResult>>

The requested page of projected results.

Type Parameters

TResult

The projection result type.

GetSingleAsync(QueryOptions<TEntity>, CancellationToken)

Gets the single element matching the supplied options, or null when none match.

Task<TEntity?> GetSingleAsync(QueryOptions<TEntity> options, CancellationToken cancellationToken = default)

Parameters

options QueryOptions<TEntity>

The query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TEntity>

The single matching entity, or null.

SumAsync(Expression<Func<TEntity, decimal>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected decimal value over the matching elements.

Task<decimal> SumAsync(Expression<Func<TEntity, decimal>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, decimal>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<decimal>

The sum of the projected values.

SumAsync(Expression<Func<TEntity, double>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected double value over the matching elements.

Task<double> SumAsync(Expression<Func<TEntity, double>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, double>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The sum of the projected values.

SumAsync(Expression<Func<TEntity, int>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected int value over the matching elements.

Task<int> SumAsync(Expression<Func<TEntity, int>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, int>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<int>

The sum of the projected values.

SumAsync(Expression<Func<TEntity, long>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected long value over the matching elements.

Task<long> SumAsync(Expression<Func<TEntity, long>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, long>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long>

The sum of the projected values.

SumAsync(Expression<Func<TEntity, decimal?>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected nullable decimal value over the matching elements.

Task<decimal?> SumAsync(Expression<Func<TEntity, decimal?>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, decimal?>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<decimal?>

The sum of the projected values, or null when the sequence is empty.

SumAsync(Expression<Func<TEntity, double?>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected nullable double value over the matching elements.

Task<double?> SumAsync(Expression<Func<TEntity, double?>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, double?>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The sum of the projected values, or null when the sequence is empty.

SumAsync(Expression<Func<TEntity, int?>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected nullable int value over the matching elements.

Task<int?> SumAsync(Expression<Func<TEntity, int?>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, int?>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<int?>

The sum of the projected values, or null when the sequence is empty.

SumAsync(Expression<Func<TEntity, long?>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected nullable long value over the matching elements.

Task<long?> SumAsync(Expression<Func<TEntity, long?>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, long?>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long?>

The sum of the projected values, or null when the sequence is empty.

SumAsync(Expression<Func<TEntity, float?>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected nullable float value over the matching elements.

Task<float?> SumAsync(Expression<Func<TEntity, float?>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, float?>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<float?>

The sum of the projected values, or null when the sequence is empty.

SumAsync(Expression<Func<TEntity, float>>, QueryOptions<TEntity>?, CancellationToken)

Computes the sum of a projected float value over the matching elements.

Task<float> SumAsync(Expression<Func<TEntity, float>> selector, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)

Parameters

selector Expression<Func<TEntity, float>>

A projection function applied to each element.

options QueryOptions<TEntity>

Optional query shaping, including the filter to apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<float>

The sum of the projected values.

See Also