DKNet.SlimBus.Extensions
10.1.16
See the version list below for details.
dotnet add package DKNet.SlimBus.Extensions --version 10.1.16
NuGet\Install-Package DKNet.SlimBus.Extensions -Version 10.1.16
<PackageReference Include="DKNet.SlimBus.Extensions" Version="10.1.16" />
<PackageVersion Include="DKNet.SlimBus.Extensions" Version="10.1.16" />
<PackageReference Include="DKNet.SlimBus.Extensions" />
paket add DKNet.SlimBus.Extensions --version 10.1.16
#r "nuget: DKNet.SlimBus.Extensions, 10.1.16"
#:package DKNet.SlimBus.Extensions@10.1.16
#addin nuget:?package=DKNet.SlimBus.Extensions&version=10.1.16
#tool nuget:?package=DKNet.SlimBus.Extensions&version=10.1.16
DKNet.SlimBus.Extensions
CQRS and messaging glue on top of SlimMessageBus, wired for EF Core —
a lighter, result-based alternative to MediatR. Command/query handlers get fluent contracts, successful writes are
auto-saved to your DbContext, and EF Core domain events are forwarded onto the bus.
Install
dotnet add package DKNet.SlimBus.Extensions
Features
- Command contracts —
Fluents.Requests.INoResponse/IWitResponse<TResponse>, with matchingIHandler<>interfaces; auto-saves theDbContextafter a successful handler, skips it on failure or null. - Query contracts —
Fluents.Queries.IWitResponse<TResponse>andIWitPageResponse<TResponse>(paged, viaX.PagedList.EF); queries never trigger auto-save. - Event consumers —
Fluents.EventsConsumers.IHandler<TEvent>for reacting to messages/domain events. - Domain event publishing —
SlimBusEventPublisherforwards events raised byDKNet.EfCore.Eventsonto the bus, copying eventAdditionalDatainto message headers. - Pluggable interceptors — auto-save is a standard SlimMessageBus
IRequestHandlerInterceptor<,>; add your own for validation, logging, etc. - Transport-agnostic — brings no provider; plug in
SlimMessageBus.Host.Memory, Azure Service Bus, or any other SlimMessageBus provider yourself.
Quick start
using DKNet.SlimBus.Extensions;
using FluentResults;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using SlimMessageBus.Host;
using SlimMessageBus.Host.Memory;
using SlimMessageBus.Host.Serialization.SystemTextJson;
services.AddDbContext<AppDbContext>(o => o.UseSqlServer(connectionString));
services.AddSlimBusEfCoreInterceptor<AppDbContext>();
services.AddSlimMessageBus(mbb => mbb
.AddJsonSerializer()
.AddServicesFromAssembly(typeof(Program).Assembly)
.AddChildBus("Memory", bus => bus
.WithProviderMemory()
.AutoDeclareFrom(typeof(Program).Assembly)));
// Command
public record CreateProduct(string Name, decimal Price) : Fluents.Requests.IWitResponse<Guid>;
internal sealed class CreateProductHandler(AppDbContext db)
: Fluents.Requests.IHandler<CreateProduct, Guid>
{
public async Task<IResult<Guid>> OnHandle(CreateProduct request, CancellationToken cancellationToken)
{
var product = new Product(request.Name, request.Price);
await db.Products.AddAsync(product, cancellationToken);
return Result.Ok(product.Id); // DbContext is saved automatically after this returns
}
}
Configuration — registration surface
There is no options type and no IConfiguration section. What you vary is which of the two registrations you
call and with which DbContext; everything else (AddSlimMessageBus, serializers, providers, handler discovery)
is SlimMessageBus's own API.
| Method | Constraint | Registers | Lifetime | Repeat call |
|---|---|---|---|---|
AddSlimBusEfCoreInterceptor<TDbContext>() |
TDbContext : DbContext |
IRequestHandlerInterceptor<,> → the internal auto-save interceptor |
Scoped | Adds TDbContext to the save registry; the interceptor is registered only once |
AddSlimBusEventPublisher<TDbContext>() |
TDbContext : DbContext |
SlimBusEventPublisher as IEventPublisher for TDbContext, via DKNet.EfCore.Events |
Delegated to AddEventPublisher |
Delegated to AddEventPublisher |
Auto-save behaviour is fixed, not switchable:
| Concern | Value |
|---|---|
| Interceptor order | int.MaxValue — runs outermost, after your own interceptors |
| Saved for | Fluents.Requests.INoResponse and Fluents.Requests.IWitResponse<T> only |
| Skipped when | The response is null, or an IResultBase with IsSuccess == false |
| Saved contexts | Every registered type whose ChangeTracker.HasChanges() |
| Save call | AddNewEntitiesFromNavigations, then SaveChangesWithConcurrencyHandlingAsync |
| Exception handler | IEfCoreExceptionHandler keyed by the DbContext's FullName, falling back to the unkeyed registration |
Public extension points
| Type | Accessibility | What you do with it |
|---|---|---|
Fluents.Requests.INoResponse / IWitResponse<T> |
public interface | Mark a message as a write — auto-save keys off exactly this. |
Fluents.Requests.IHandler<TRequest> / IHandler<TRequest, TResponse> |
public interface | Implement the handler for a write. |
Fluents.Requests.IWithKey<TKey> |
public interface | Carry a route-bound Id. |
Fluents.Queries.IWitResponse<T> / IWitPageResponse<T> and their handlers |
public interface | Mark and handle a read. Never auto-saved. |
Fluents.EventsConsumers.IHandler<TEvent> |
public interface | Consume a published event. |
SlimBusEventPublisher |
public class, both PublishAsync overloads virtual |
Subclass to add headers or logging, then register the subclass. |
NotFoundError |
public sealed class : FluentResults.Error |
Return it from Result.Fail so the API layer maps one type to 404. |
ILazyMap<T>, LazyMapExtensions.LazyMap<T> / ResultOf<T> |
public interface / public static class | Defer a Mapster mapping until the value is read. |
RequestBase |
public record, [Obsolete] |
Nothing — never populated by this package. |
The auto-save interceptor, its DbContext registry, and the LazyMap/LazyResult implementations are all
internal: you opt in through the two registration methods, not by implementing those types.
Documentation
Full feature reference, diagrams, and composition with DKNet.EfCore.Events / DKNet.EfCore.Specifications:
https://github.com/baoduy/DKNet/blob/main/docs/Messaging/DKNet.SlimBus.Extensions.md
| 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
- DKNet.EfCore.Events (>= 10.1.16)
- FluentResults (>= 4.0.0)
- Mapster (>= 10.0.12)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.11)
- SlimMessageBus (>= 3.0.0)
- SlimMessageBus.Host (>= 3.5.0)
- SlimMessageBus.Host.Interceptor (>= 3.0.0)
- X.PagedList.EF (>= 10.5.9)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DKNet.SlimBus.Extensions:
| Package | Downloads |
|---|---|
|
DKNet.AspCore.SlimBus
Package Description |
|
|
DKNet.AspCore.Extensions
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.19 | 67 | 9/3/2026 |
| 10.1.18 | 56 | 9/3/2026 |
| 10.1.17 | 63 | 9/3/2026 |
| 10.1.16 | 66 | 9/3/2026 |
| 10.1.15 | 114 | 9/1/2026 |
| 10.1.14 | 78 | 9/1/2026 |
| 10.1.13 | 90 | 8/31/2026 |
| 10.1.12 | 113 | 8/25/2026 |
| 10.1.11 | 117 | 8/24/2026 |
| 10.1.10 | 115 | 8/22/2026 |
| 10.1.9 | 118 | 8/22/2026 |
| 10.1.8 | 119 | 8/21/2026 |
| 10.1.7 | 126 | 8/21/2026 |
| 10.1.6 | 114 | 8/21/2026 |
| 10.1.5 | 181 | 8/20/2026 |
| 10.1.4 | 105 | 8/20/2026 |
| 10.1.3 | 105 | 8/19/2026 |
| 10.1.2 | 108 | 8/19/2026 |
| 10.1.1 | 92 | 8/19/2026 |
| 10.0.36 | 95 | 8/18/2026 |