Koto.Domain
0.1.0-preview.5
dotnet add package Koto.Domain --version 0.1.0-preview.5
NuGet\Install-Package Koto.Domain -Version 0.1.0-preview.5
<PackageReference Include="Koto.Domain" Version="0.1.0-preview.5" />
<PackageVersion Include="Koto.Domain" Version="0.1.0-preview.5" />
<PackageReference Include="Koto.Domain" />
paket add Koto.Domain --version 0.1.0-preview.5
#r "nuget: Koto.Domain, 0.1.0-preview.5"
#:package Koto.Domain@0.1.0-preview.5
#addin nuget:?package=Koto.Domain&version=0.1.0-preview.5&prerelease
#tool nuget:?package=Koto.Domain&version=0.1.0-preview.5&prerelease
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 | 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
- 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 |