Levge.MediatR 2.3.0

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

Publish NuGet Package

Levge.MediatR

MediatR tabanlı domain event dispatcher ve EF Core interceptor. IDomainEventDispatcher implementasyonu ve SaveChanges sonrası otomatik domain event dispatch altyapısı sağlar.

Kurulum

dotnet add package Levge.MediatR

İçerik

Sınıf Açıklama
DomainEventNotification<T> DomainEvent'i MediatR INotification'a saran wrapper
MediatRDomainEventDispatcher IDomainEventDispatcher'ın MediatR implementasyonu
DomainEventDispatchInterceptor EF Core SaveChangesInterceptorSavedChangesAsync sonrası event dispatch eder
AddLevgeMediatR() MediatR'ı ve handler'ları DI'a kaydeder
AddLevgeDomainEventInterceptors() DomainEventDispatchInterceptor'ı DbContext'e ekler

Kullanım

1. DI Kaydı

// Infrastructure/DependencyInjection.cs
services.AddLevgeMediatR(Assembly.GetExecutingAssembly());

services.AddDbContext<AppDbContext>((sp, options) =>
{
    options.UseSqlServer(connectionString);
    options.AddLevgeDomainEventInterceptors(sp);
});

2. Domain Event Tanımla

// Domain/Events/OrderCreatedEvent.cs
public sealed record OrderCreatedEvent(long OrderId, decimal Total) : DomainEvent;

3. Entity'de Event Yayımla

public class Order : FullAuditableEntity
{
    public static Order Create(long customerId, decimal total, long createdByUserId)
    {
        var order = new Order { ... };
        order.RaiseDomainEvent(new OrderCreatedEvent(order.Id, total));
        return order;
    }
}

4. Handler Yaz

// Infrastructure/EventHandlers/OrderCreatedEventHandler.cs
public class OrderCreatedEventHandler : INotificationHandler<DomainEventNotification<OrderCreatedEvent>>
{
    public async Task Handle(DomainEventNotification<OrderCreatedEvent> notification, CancellationToken cancellationToken)
    {
        var @event = notification.DomainEvent;
        // işlemler...
    }
}

Lisans

MIT © Serdar ÖZKAN

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
2.3.0 108 4/29/2026
2.1.0 99 4/27/2026
2.0.1 97 4/27/2026