Despro.Framework.Application
2.0.8
dotnet add package Despro.Framework.Application --version 2.0.8
NuGet\Install-Package Despro.Framework.Application -Version 2.0.8
<PackageReference Include="Despro.Framework.Application" Version="2.0.8" />
<PackageVersion Include="Despro.Framework.Application" Version="2.0.8" />
<PackageReference Include="Despro.Framework.Application" />
paket add Despro.Framework.Application --version 2.0.8
#r "nuget: Despro.Framework.Application, 2.0.8"
#:package Despro.Framework.Application@2.0.8
#addin nuget:?package=Despro.Framework.Application&version=2.0.8
#tool nuget:?package=Despro.Framework.Application&version=2.0.8
Despro.Framework.Application
The application (CQRS) layer of Despro Framework.
Despro.Framework.Application defines the CQRS contracts (commands, queries and their
handlers) built on MediatR, plus the FluentValidation pipeline behavior that validates every
command before it reaches a handler. This is the layer your use cases build directly on.
- Package:
Despro.Framework.Application - Version:
2.0.5 - Target framework:
net10.0 - Depends on:
Despro.Framework.Base, MediatR 14.0.0
Installation
dotnet add package Despro.Framework.Application
DI registration
using Despro.Framework.Application;
builder.Services.AddFrameworkApplication();
AddFrameworkApplication registers the CommandValidationBehavior<,> MediatR pipeline
behavior and scans this assembly for FluentValidation validators. (The assemblies that
contain your handlers/validators are registered separately by
AddFrameworkInfrastructure.)
CQRS contracts (QueryCommandTools)
Commands — state-changing operations
| Contract | Returns |
|---|---|
ICommand |
OperationResult |
ICommand<TResponse> |
OperationResult<TResponse> |
ICommandHandler<TCommand> |
handles ICommand |
ICommandHandler<TCommand, TResponseData> |
handles ICommand<TResponseData> |
Queries — read operations
| Contract | Returns |
|---|---|
IQuery<TResponse> |
TResponse |
IQueryOperation<TResponse> |
OperationQueryResult<TResponse> |
QueryGrid<TResponse> (abstract, TResponse : BaseDto) |
GridData<TResponse> |
QueryGridOperation<TResponse> (abstract, TResponse : BaseDto) |
OperationQueryResult<GridData<TResponse>> |
Each query contract has a matching handler interface: IQueryHandler<,>,
IQueryOperationHandler<,>, IQueryGridHandler<,>, IQueryGridOperationHandler<,>.
Validation pipeline
CommandValidationBehavior<TRequest, TResponse> runs all registered
IValidator<TRequest> instances before the handler executes. If any rule fails it
aggregates the messages and throws InvalidCommandException, short-circuiting the pipeline
so handlers only ever run against valid input.
Exceptions (ApplicationExceptions)
BaseApplicationException(abstract, extendsBase'sBaseException).InvalidCommandException— thrown by the validation behavior on validation failure.
Usage
// Command
public record CreateProductCommand(string Name, decimal Price) : ICommand<long>;
public class CreateProductCommandValidator : AbstractValidator<CreateProductCommand>
{
public CreateProductCommandValidator()
{
RuleFor(x => x.Name).NotEmpty();
RuleFor(x => x.Price).GreaterThan(0);
}
}
public class CreateProductCommandHandler : ICommandHandler<CreateProductCommand, long>
{
public async Task<OperationResult<long>> Handle(CreateProductCommand request, CancellationToken ct)
{
// ... persist and return
return OperationResult<long>.Success(newId);
}
}
// Grid query
public class ProductGridQuery(BaseGrid grid) : QueryGrid<ProductDto>(grid);
public class ProductGridQueryHandler : IQueryGridHandler<ProductGridQuery, ProductDto>
{
public Task<GridData<ProductDto>> Handle(ProductGridQuery request, CancellationToken ct) { /* ... */ }
}
Dispatch through MediatR's ISender/IMediator; the validation behavior runs automatically.
Project structure
Despro.Framework.Application
├── ApplicationExceptions/ # BaseApplicationException, InvalidCommandException
├── QueryCommandTools/ # ICommand, IQuery, QueryGrid, CommandValidationBehavior
└── FrameworkApplicationDi.cs # AddFrameworkApplication
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Despro.Framework.Base (>= 2.1.2)
- MediatR (>= 14.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.