Domain.Primitives 1.0.1

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

Core

Lightweight Domain-Driven Design (DDD) building blocks for .NET — typed identifiers, entity contracts, aggregate roots with domain events, and optimistic concurrency versioning.

Targets .NET 10 with no external dependencies.

Installation

dotnet add package Domain.Primitives

What's included

Type Description
Id Abstract record wrapping a Guid for strongly typed entity identifiers
IEntity<T> Contract for entities with a typed Id
IAggregate<T> Extends IEntity<T> with a domain event queue and ClearEvents()
Aggregate<TId> Base aggregate with version tracking and protected AddEvent() / IncrementVersion()
IEvent Domain event interface with default Id, OccurredOn, and EventType

Usage

Typed IDs and aggregates

using Core;

public sealed record OrderId(Guid Value) : Id(Value);

public sealed class OrderCreated : IEvent;

public sealed class Order : Aggregate<OrderId>
{
    public override OrderId Id { get; }

    public Order(OrderId id)
    {
        Id = id;
        AddEvent(new OrderCreated());
    }

    public void Ship()
    {
        AddEvent(new OrderShipped());
    }
}

public sealed class OrderShipped : IEvent;

Dispatching domain events

After persisting an aggregate, dequeue and handle its pending events (e.g. for an outbox or in-process dispatcher):

Order order = /* load or create */;

// ... apply business logic that calls AddEvent ...

IEvent[] pendingEvents = order.ClearEvents();

foreach (IEvent domainEvent in pendingEvents)
{
    // publish or persist for downstream handlers
}

Versioning

Aggregate<TId> tracks an Version property for optimistic concurrency. The version increments once when the first domain event is raised or when IncrementVersion() is called — whichever happens first in a given change cycle.

Development

Clone the repository and run tests:

git clone https://github.com/mohamadkaramidarabi/Domain.Core.git
cd Domain.Core
dotnet test tests/Core.Test/Core.Test.csproj

Build a NuGet package locally:

dotnet pack src/Core/Core.csproj -c Release -o ./artifacts

Releasing

Releases are published to nuget.org via GitHub Actions when a version tag is pushed (e.g. v1.0.0). The tag version should match the <Version> in Core.csproj.

License

MIT

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.
  • net10.0

    • No dependencies.

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
1.0.1 135 7/2/2026
1.0.0 120 6/12/2026