Mehedi.Core.SharedKernel.Net10 2.0.1

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

NuGet NuGet Downloads CI

Mehedi.Core.SharedKernel

Reusable base classes and interfaces for Domain-Driven Design (DDD) in .NET. Published as two packages — one per target framework.

Installation

.NET 8:

dotnet add package Mehedi.Core.SharedKernel

.NET 10:

dotnet add package Mehedi.Core.SharedKernel.Net10

What's included

Type Purpose
BaseEntity<TKey> Abstract entity with typed key and domain event collection
IAggregateRoot Marks an aggregate root; exposes DomainEvents / ClearDomainEvents
BaseDomainEvent Abstract record for domain events; stores MessageType, AggregateId (string), OccurredOn
IDomainEvent Thin wrapper over MediatR INotification
ValueObject Abstract base with structural equality via GetEqualityComponents()
Enumerations Rich enum base class with GetAll<T>(), FromValue<T>(), FromDisplayName<T>()
ICommandRepository<T,TKey> Write-side repository contract with CancellationToken on all methods
IQueryRepository<T,TKey> Read-side repository contract returning PagedResult<T>
PagedResult<T> Wraps a page of results with Total count and Items list
IUnitOfWork SaveChangesAsync(CancellationToken)

Quick start

1. Define an entity

public class Order : BaseEntity<Guid>, IAggregateRoot
{
    public string CustomerName { get; private set; } = string.Empty;

    private Order() { }

    public static Order Place(string customerName)
    {
        var order = new Order { CustomerName = customerName };
        order.AddDomainEvent(new OrderPlacedEvent(order.Id, customerName));
        return order;
    }

    protected override Guid GenerateNewId() => Guid.NewGuid();
}

2. Define a domain event

// AggregateId is string — works with Guid, long, or any key type
public record OrderPlacedEvent(Guid OrderId, string CustomerName)
    : BaseDomainEvent(nameof(OrderPlacedEvent), OrderId.ToString());

3. Define a value object

public sealed class Money : ValueObject
{
    public decimal Amount { get; }
    public string Currency { get; }

    public Money(decimal amount, string currency)
    {
        Amount = amount;
        Currency = currency;
    }

    protected override IEnumerable<object> GetEqualityComponents()
    {
        yield return Amount;
        yield return Currency;
    }
}

4. Define a rich enumeration

public sealed class OrderStatus : Enumerations
{
    public static readonly OrderStatus Pending   = new(1, "Pending");
    public static readonly OrderStatus Confirmed = new(2, "Confirmed");
    public static readonly OrderStatus Shipped   = new(3, "Shipped");

    private OrderStatus(int id, string name) : base(id, name) { }
}

// Usage
var all    = Enumerations.GetAll<OrderStatus>();
var status = Enumerations.FromValue<OrderStatus>(2);       // Confirmed
var same   = Enumerations.FromDisplayName<OrderStatus>("Shipped");

5. Implement a repository

public class OrderRepository : ICommandRepository<Order, Guid>
{
    private readonly AppDbContext _db;
    public OrderRepository(AppDbContext db) => _db = db;

    public async Task<Order?> GetByIdAsync(Guid id, CancellationToken ct = default)
        => await _db.Orders.FindAsync([id], ct);

    public async Task<Order> AddAsync(Order entity, CancellationToken ct = default)
    {
        await _db.Orders.AddAsync(entity, ct);
        return entity;
    }

    // ... other interface members
}

6. Dispatch domain events

// After SaveChangesAsync, dispatch and clear events:
foreach (var evt in order.DomainEvents)
    await mediator.Publish(evt, cancellationToken);

order.ClearDomainEvents();

.NET version matrix

Feature net8.0 net10.0
All base classes ✓ ✓
TimeProvider for OccurredOn ✓ ✓
AddDomainEvents(params ReadOnlySpan<IDomainEvent>) — ✓

Releasing a new version

git tag v1.0.0 && git push --tags        # stable release
git tag v1.0.0-rc.1 && git push --tags   # pre-release

A single tag publishes both packages. The Net10 package version is always (major+1).minor.patch:

Tag Mehedi.Core.SharedKernel Mehedi.Core.SharedKernel.Net10
v1.0.0 1.0.0 2.0.0
v1.1.0 1.1.0 2.1.0
v1.0.0-rc.1 1.0.0-rc.1 2.0.0-rc.1

References

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.0.1 115 6/22/2026
2.0.0 113 6/22/2026