Koto.Domain 0.1.0-preview.5

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

Koto.Domain

DDD building blocks for .NET microservices. Zero external dependencies.

Install

dotnet add package Koto.Domain

What's included

Type Purpose
AggregateRoot<TId> Base class that collects domain events
Entity<TId> Identity-based equality
ValueObject Component-based equality
StronglyTypedId<T> Typed wrappers for Guid / int / string IDs
Result<T> Explicit success/failure without exceptions
Error Structured error: Code + Message
Errors.General Shared factory errors (not-found, required, …)
IRepository<TAgg, TId> Persistence contract for aggregates
IDomainEvent / DomainEvent Event interfaces and base record
Unit Return type for commands that produce no value

Usage

Value Object

public sealed class Email : ValueObject
{
    public string Value { get; }
    private Email(string value) => Value = value;

    public static Result<Email> Create(string value) =>
        string.IsNullOrWhiteSpace(value) ? Errors.General.ValueIsRequired() :
        value.Length > 150              ? Errors.General.InvalidLength(1, 150) :
                                          new Email(value);

    protected override IEnumerable<object?> GetEqualityComponents()
    {
        yield return Value.ToLowerInvariant();
    }
}

Aggregate Root

public sealed record OrderId(Guid Value) : StronglyTypedId<Guid>(Value);

public class Order : AggregateRoot<OrderId>
{
    public static Result<Order> Place(IReadOnlyList<OrderItem> items)
    {
        if (items.Count == 0)
            return Errors.General.CollectionIsTooSmall(1, 0);

        var order = new Order(new OrderId(Guid.NewGuid()));
        order.AddDomainEvent(new OrderPlacedEvent(order.Id));
        return order;
    }

    public Result<Unit> Cancel(string reason)
    {
        if (Status == OrderStatus.Cancelled)
            return new Error("orders.already-cancelled", "Order is already cancelled.");

        Status = OrderStatus.Cancelled;
        AddDomainEvent(new OrderCancelledEvent(Id, reason));
        return Unit.Value;
    }
}

Result chaining

Result<OrderId> result = await ValidateAsync(request)
    .BindAsync(dto => Order.Place(dto.Items))
    .TapAsync(order => repository.Add(order))
    .MapAsync(order => order.Id);

Repository

public interface IOrderRepository : IRepository<Order, OrderId> { }

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 (6)

Showing the top 5 NuGet packages that depend on Koto.Domain:

Package Downloads
Koto.Application

CQRS dispatcher, pipeline behaviors, and cross-service integration abstractions for .NET microservices. Depends only on Koto.Domain and Microsoft.Extensions abstractions.

Koto.Validation

FluentValidation v7 extensions for Koto: MustBeValueObject, MustBeEntity, ListMustContainNumberOfItems, and ValidationBehavior pipeline integration.

Koto.EventSourcing.Marten

Event Sourcing on PostgreSQL via Marten 8: EventSourcedAggregateRoot, event-sourced repository, inline and async projections.

Koto.Infrastructure.Http

Anti-Corruption Layer for HTTP calls between services: typed ServiceHttpClient base, Result-mapped error handling, correlation ID propagation, and standard resilience.

Koto.Infrastructure.EFCore

EF Core 10 integration for Koto DDD: generic repository, strongly-typed ID converters, specification pattern, and Wolverine outbox wiring.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.5 40 5/13/2026
0.1.0-preview.4 40 5/13/2026
0.1.0-preview.3 43 5/13/2026
0.1.0-preview.2 47 5/11/2026
0.1.0-preview.1 44 5/11/2026