Class AbstractListQueryHandler<TQuery, TResponse, TDbContext, TEntity, TKey>
- Namespace
- Whipstaff.MediatR.EntityFrameworkCore
- Assembly
- Whipstaff.MediatR.EntityFrameworkCore.dll
Base class for an EFCore List Operation.
public abstract class AbstractListQueryHandler<TQuery, TResponse, TDbContext, TEntity, TKey> : IQueryHandler<TQuery, TResponse[]>, IRequestHandler<TQuery, TResponse[]?> where TQuery : IQuery<TResponse[]>, IPageRequest where TDbContext : DbContext where TEntity : class
Type Parameters
TQuery
The type for the query.
TResponse
The type for the CQRS response.
TDbContext
The type for the Entity Framework DB Context.
TEntity
The type for the Entity Framework Entity being queried.
TKey
The type for the Entity Primary Key.
- Inheritance
-
AbstractListQueryHandler<TQuery, TResponse, TDbContext, TEntity, TKey>
- Implements
-
IQueryHandler<TQuery, TResponse[]>IRequestHandler<TQuery, TResponse[]>
- Inherited Members
Constructors
AbstractListQueryHandler()
protected AbstractListQueryHandler()
Methods
GetDbContext()
Gets the DBContext instance for use in the query.
protected abstract TDbContext GetDbContext()
Returns
- TDbContext
DBContext instance.
GetDbSet(TDbContext)
Gets the DBSet for use in the query.
protected abstract DbSet<TEntity> GetDbSet(TDbContext dbContext)
Parameters
dbContext
TDbContextThe DB Context instance to use.
Returns
- DbSet<TEntity>
The DBSet.
GetOrderingExpression()
Gets the ordering expression for use in the EF query.
protected abstract Expression<Func<TEntity, TKey>>? GetOrderingExpression()
Returns
- Expression<Func<TEntity, TKey>>
Expression representing the query ordering.
GetSelectorExpression()
Gets the selector expression for use in the EF query. Used for mapping EF Core entities to an output POCO object.
protected abstract Expression<Func<TEntity, int, TResponse>> GetSelectorExpression()
Returns
- Expression<Func<TEntity, int, TResponse>>
Expression representing the output selection.
GetWherePredicateExpression()
Gets the expression representing the where filter predicate.
protected abstract Expression<Func<TEntity, int, bool>> GetWherePredicateExpression()
Returns
- Expression<Func<TEntity, int, bool>>
Expression representing the where clause.
GetWhetherOrderingIsByDescending()
Gets a flag indicating whether the ordering is descending or not.
protected abstract bool GetWhetherOrderingIsByDescending()
Returns
- bool
True if descending, otherwise false.
Handle(TQuery, CancellationToken)
Handles a request
public Task<TResponse[]?> Handle(TQuery request, CancellationToken cancellationToken)
Parameters
request
TQueryThe request
cancellationToken
CancellationTokenCancellation token
Returns
- Task<TResponse[]>
Response from the request