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
TEntityThe item to act on.
Returns
GetQueryAsync(TDbContext)
Gets the query to be executed.
protected abstract Task<IQueryable<TEntity>> GetQueryAsync(TDbContext dbContext)
Parameters
dbContext
TDbContextThe 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
TRequestThe request
cancellationToken
CancellationTokenCancellation token