Table of Contents

Class ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity>

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

MediatR request handler for acting on an entity framework dbset.

public abstract class ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity> : IRequestHandler<TRequest, int> where TRequest : IRequest<int> where TDbContext : DbContext

Type Parameters

TRequest

The type for the MediatR Request.

TDbContext

The type for the Entity Framework DB Context.

TEntity

The type for the POCO object.

Inheritance
ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity>
Implements
IRequestHandler<TRequest, int>
Inherited Members

Constructors

ActOnDbSetRequestHandler(IDbContextFactory<TDbContext>, ILogger<ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity>>)

Initializes a new instance of the ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity> class.

protected ActOnDbSetRequestHandler(IDbContextFactory<TDbContext> dbContextFactory, ILogger<ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity>> logger)

Parameters

dbContextFactory IDbContextFactory<TDbContext>

The factory for the database context.

logger ILogger<ActOnDbSetRequestHandler<TRequest, TDbContext, TEntity>>

Logging framework instance.

Methods

ActOnItemAsync(TEntity)

Allows acting on a strongly typed entity.

protected abstract Task ActOnItemAsync(TEntity item)

Parameters

item TEntity

The item to act on.

Returns

Task

A Task representing the result of the asynchronous operation.

GetQueryAsync(TDbContext)

Gets the query to be executed.

protected abstract Task<IQueryable<TEntity>> GetQueryAsync(TDbContext dbContext)

Parameters

dbContext TDbContext

The Database Context.

Returns

Task<IQueryable<TEntity>>

A Task<TResult> representing the result of the asynchronous operation.

Handle(TRequest, CancellationToken)

Handles a request

public Task<int> Handle(TRequest request, CancellationToken cancellationToken)

Parameters

request TRequest

The request

cancellationToken CancellationToken

Cancellation token

Returns

Task<int>

Response from the request