Application.Abstraction 1.0.0

dotnet add package Application.Abstraction --version 1.0.0
                    
NuGet\Install-Package Application.Abstraction -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Application.Abstraction" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Application.Abstraction" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Application.Abstraction" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Application.Abstraction --version 1.0.0
                    
#r "nuget: Application.Abstraction, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Application.Abstraction@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Application.Abstraction&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Application.Abstraction&version=1.0.0
                    
Install as a Cake Tool

Application.Abstraction

A lightweight .NET library that provides CQRS abstractions for application layers. Combine SimpleMediator with Core.Result to return explicit success and failure outcomes from commands and queries.

Features

  • Command and query marker interfaces (ICommand, IQuery<T>)
  • Base handlers with built-in Success() and Failure() builders
  • Domain status enums (SuccessResult, FailureResult) for HTTP-friendly mapping
  • JSON serialization support via JsonStringEnumConverter
  • Zero boilerplate — handlers inherit fluent result building from CustomRequestHandler

Installation

dotnet add package Application.Abstraction

Or via Package Manager:

Install-Package Application.Abstraction

Quick Start

Define a command

using Application.Abstraction.CQRS.Command;

public sealed record CreateItemCommand(string Name) : ICommand<string>;

Implement a command handler

using Application.Abstraction.CQRS.Command;
using Application.Abstraction.CQRS.Result;
using Core.Result;

public sealed class CreateItemCommandHandler : CommandHandler<CreateItemCommand, string>
{
    public override Task<Result<string, SuccessResult, FailureResult>> Handle(
        CreateItemCommand request,
        CancellationToken cancellationToken)
    {
        return Task.FromResult<Result<string, SuccessResult, FailureResult>>(
            Success(SuccessResult.Created)
                .WithData(request.Name)
                .WithMessage("Item created")
                .Build());
    }
}

Define a query

using Application.Abstraction.CQRS.Query;

public sealed record GetItemQuery(string Id) : IQuery<ItemDto>;

Implement a query handler

using Application.Abstraction.CQRS.Query;
using Application.Abstraction.CQRS.Result;
using Core.Result;

public sealed class GetItemQueryHandler : QueryHandler<GetItemQuery, ItemDto>
{
    public override Task<Result<ItemDto, SuccessResult, FailureResult>> Handle(
        GetItemQuery request,
        CancellationToken cancellationToken)
    {
        var item = FindItem(request.Id);
        if (item is null)
        {
            return Task.FromResult<Result<ItemDto, SuccessResult, FailureResult>>(
                Failure(FailureResult.NotFound)
                    .WithMessage("Item not found")
                    .AppendErrors([$"No item with id '{request.Id}'"])
                    .Build());
        }

        return Task.FromResult<Result<ItemDto, SuccessResult, FailureResult>>(
            Success(SuccessResult.Done)
                .WithData(item)
                .Build());
    }
}

Commands without a response payload

Use ICommand (alias for ICommand<Unit>) when an operation succeeds without returning data:

public sealed record DeleteItemCommand(string Id) : ICommand;

public sealed class DeleteItemCommandHandler : CommandHandler<DeleteItemCommand>
{
    public override Task<Result<Unit, SuccessResult, FailureResult>> Handle(
        DeleteItemCommand request,
        CancellationToken cancellationToken)
    {
        return Task.FromResult<Result<Unit, SuccessResult, FailureResult>>(
            Success(SuccessResult.NoContent)
                .WithData(Unit.Value)
                .Build());
    }
}

Status Enums

SuccessResult

Value Typical use
Done General success
Created Resource created (201)
NoContent Success with no body (204)
Modified Resource updated (200/204)

FailureResult

Value Typical use
Validation Invalid input (400)
NotFound Resource missing (404)
Unauthorized Authentication required (401)
Forbidden Access denied (403)
Server Unexpected error (500)
Timeout Operation timed out (504)

Map these statuses to HTTP responses, problem details, or integration events in your API layer — not inside domain handlers.

API Overview

Type Description
ICommand Marker for commands that return Unit
ICommand<TResponse> Marker for commands that return a typed result
IQuery<TResponse> Marker for queries that return a typed result
CommandHandler<TCommand> Base handler for commands without a payload
CommandHandler<TCommand, TResponse> Base handler for commands with a payload
QueryHandler<TQuery, TResponse> Base handler for queries
CustomRequestHandler<TRequest, TResponse> Shared base with Success() and Failure() helpers

All handlers return Result<TResponse, SuccessResult, FailureResult> from Core.Result.

Dependencies

Requirements

  • .NET 10.0

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 51 6/7/2026