EntityAxis.MediatR
1.0.0
dotnet add package EntityAxis.MediatR --version 1.0.0
NuGet\Install-Package EntityAxis.MediatR -Version 1.0.0
<PackageReference Include="EntityAxis.MediatR" Version="1.0.0" />
<PackageVersion Include="EntityAxis.MediatR" Version="1.0.0" />
<PackageReference Include="EntityAxis.MediatR" />
paket add EntityAxis.MediatR --version 1.0.0
#r "nuget: EntityAxis.MediatR, 1.0.0"
#:package EntityAxis.MediatR@1.0.0
#addin nuget:?package=EntityAxis.MediatR&version=1.0.0
#tool nuget:?package=EntityAxis.MediatR&version=1.0.0
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
๐ Related Packages
- 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 | Versions 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. |
-
net8.0
- AutoMapper (>= 14.0.0)
- EntityAxis.Abstractions (>= 1.0.0)
- FluentValidation (>= 11.11.0)
- MediatR (>= 12.4.1)
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 |