EntityAxis.MediatR 1.0.0

dotnet add package EntityAxis.MediatR --version 1.0.0
                    
NuGet\Install-Package EntityAxis.MediatR -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="EntityAxis.MediatR" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EntityAxis.MediatR" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EntityAxis.MediatR" />
                    
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 EntityAxis.MediatR --version 1.0.0
                    
#r "nuget: EntityAxis.MediatR, 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 EntityAxis.MediatR@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=EntityAxis.MediatR&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EntityAxis.MediatR&version=1.0.0
                    
Install as a Cake Tool

EntityAxis.MediatR

EntityAxis.MediatR provides fully generic MediatR command and query handlers that work out of the box with the interfaces defined in EntityAxis.Abstractions. It is designed for use in Clean Architecture applications that already use MediatR and AutoMapper.

โœจ Features

  • Generic MediatR command/query handlers for:
    • CreateEntityCommand
    • UpdateEntityCommand
    • DeleteEntityCommand
    • GetEntityByIdQuery
    • GetAllEntitiesQuery
    • GetPagedEntitiesQuery
  • AutoMapper support for mapping between models and entities
  • FluentValidation integration with runtime safeguards and friendly errors
  • Supports TKey flexibility: string, Guid, int, etc.

๐Ÿ“ฆ Installation

dotnet add package EntityAxis.MediatR

๐Ÿงฑ Example Usage

public class CreateUserModel
{
    public string Email { get; set; }
}

public class User : IEntityId<Guid>
{
    public Guid Id { get; set; }
    public string Email { get; set; }
}

// Configure AutoMapper
CreateMap<CreateUserModel, User>();

// MediatR Request
var id = await mediator.Send(new CreateEntityCommand<CreateUserModel, User, Guid>(model));

โœ… Be sure to register your AutoMapper mappings, and register handlers using AddEntityAxisHandlers() from the EntityAxis.Registration package (recommended for DI setup).

๐Ÿงช Validation Integration

All handlers are paired with generic FluentValidation validators that:

  • Validate required input (e.g., Id, paging params)
  • Compose with your own model validators (e.g., CreateUserModelValidator)
  • Throw clear and early errors if a validator is missing

To validate custom fields (e.g., email formatting), define a validator like:

public class CreateUserModelValidator : AbstractValidator<CreateUserModel>
{
    public CreateUserModelValidator()
    {
        RuleFor(x => x.Email).NotEmpty().EmailAddress();
    }
}

This will be automatically invoked by the CreateEntityValidator<TModel, TEntity, TKey>.


๐Ÿง  Why Use EntityAxis

  • Consistent patterns across your app
  • Eliminate repetitive CRUD boilerplate
  • Stay aligned with CQRS and Clean Architecture principles
  • Focus on behavior and intent, not infrastructure
  • EntityAxis.Abstractions: Defines common CRUD contracts (IGetById, ICreate, etc.) and domain-friendly interfaces for clean application layers.
  • EntityAxis.EntityFramework: Drop-in base classes for EF Core integration
  • EntityAxis.Registration: Offers IServiceCollection extension methods to register handlers, validators, and mapping configuration easily in your DI container.

๐Ÿ“œ License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on EntityAxis.MediatR:

Package Downloads
EntityAxis.MediatR.Registration

Offers registration helpers and fluent APIs for adding MediatR handlers and validators using the EntityAxis generic conventions. Supports command and query handlers for Create, Update, Delete, GetById, GetAll, and GetPaged flows with AutoMapper validation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 158 5/5/2025
0.2.0 124 5/4/2025
0.1.1 165 4/28/2025
0.1.0 183 4/13/2025
0.0.1-beta 162 4/7/2025