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
TEntityThe type of the entity.
TKeyThe 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
predicateExpression<Func<TEntity, bool>>The predicate that every element must satisfy.
optionsQueryOptions<TEntity>Optional query shaping, including a scope filter to apply first.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
specificationISpecification<TEntity>The specification to apply.
optionsQueryOptions<TEntity>Optional additional query shaping.
cancellationTokenCancellationTokenThe 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
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
CountAsync(QueryOptions<TEntity>?, CancellationToken)
Counts the elements matching the supplied options.
Task<long> CountAsync(QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)
Parameters
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
GetAllAsync(QueryOptions<TEntity>?, CancellationToken)
Gets all elements, optionally shaped by options.
Task<IEnumerable<TEntity>> GetAllAsync(QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)
Parameters
optionsQueryOptions<TEntity>Optional query shaping (filter, sorting, includes, tracking).
cancellationTokenCancellationTokenThe 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
idTKeyThe entity key.
optionsQueryOptions<TEntity>Optional query shaping.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TEntity>
The entity, or
nullwhen 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
filterExpression<Func<TEntity, bool>>The predicate to apply.
optionsQueryOptions<TEntity>Optional additional query shaping.
cancellationTokenCancellationTokenThe 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
optionsQueryOptions<TEntity>The query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe 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
mapExpression<Func<TEntity, TResult>>The projection to apply.
optionsQueryOptions<TEntity>The query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TResult>
The first projected result, or the default when none match.
Type Parameters
TResultThe 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
mapExpression<Func<TEntity, TResult>>The projection to apply.
optionsQueryOptions<TEntity>Optional query shaping (filter, sorting, includes, tracking).
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IEnumerable<TResult>>
The projected results.
Type Parameters
TResultThe 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
pagePageRequestThe page to retrieve.
optionsQueryOptions<TEntity>Optional query shaping (filter, sorting, includes, tracking).
cancellationTokenCancellationTokenThe 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
pagePageRequestThe page to retrieve.
mapExpression<Func<TEntity, TResult>>The projection to apply.
optionsQueryOptions<TEntity>Optional query shaping (filter, sorting, includes, tracking).
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<PagedResult<TResult>>
The requested page of projected results.
Type Parameters
TResultThe 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
optionsQueryOptions<TEntity>The query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe 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
selectorExpression<Func<TEntity, decimal>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, double>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, int>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, long>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, decimal?>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, double?>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, int?>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, long?>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, float?>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
selectorExpression<Func<TEntity, float>>A projection function applied to each element.
optionsQueryOptions<TEntity>Optional query shaping, including the filter to apply.
cancellationTokenCancellationTokenThe cancellation token.