Table of Contents

Class AbstractViewQueryHandler<TQuery, TResponse, TDbContext, TEntity>

Namespace
Whipstaff.MediatR.EntityFrameworkCore
Assembly
Whipstaff.MediatR.EntityFrameworkCore.dll

Base class for fetching a single record from mediatr.

public abstract class AbstractViewQueryHandler<TQuery, TResponse, TDbContext, TEntity> : IQueryHandler<TQuery, TResponse?>, IRequestHandler<TQuery, TResponse?> where TQuery : IQuery<TResponse?> where TDbContext : DbContext where TEntity : class

Type Parameters

TQuery

The request type for the MediatR query.

TResponse

The response type coming out of MediatR.

TDbContext

The type for the Entity Framework DB Context.

TEntity

The type for the Entity Framework DB Set.

Inheritance
AbstractViewQueryHandler<TQuery, TResponse, TDbContext, TEntity>
Implements
IQueryHandler<TQuery, TResponse>
IRequestHandler<TQuery, TResponse>
Inherited Members

Constructors

AbstractViewQueryHandler()

protected AbstractViewQueryHandler()

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 TDbContext

The DB Context instance to use.

Returns

DbSet<TEntity>

The DBSet.

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.

Handle(TQuery, CancellationToken)

Handles a request

public Task<TResponse?> Handle(TQuery request, CancellationToken cancellationToken)

Parameters

request TQuery

The request

cancellationToken CancellationToken

Cancellation token

Returns

Task<TResponse>

Response from the request