PouryaKit.Domain
0.1.0-preview.2
dotnet add package PouryaKit.Domain --version 0.1.0-preview.2
NuGet\Install-Package PouryaKit.Domain -Version 0.1.0-preview.2
<PackageReference Include="PouryaKit.Domain" Version="0.1.0-preview.2" />
<PackageVersion Include="PouryaKit.Domain" Version="0.1.0-preview.2" />
<PackageReference Include="PouryaKit.Domain" />
paket add PouryaKit.Domain --version 0.1.0-preview.2
#r "nuget: PouryaKit.Domain, 0.1.0-preview.2"
#:package PouryaKit.Domain@0.1.0-preview.2
#addin nuget:?package=PouryaKit.Domain&version=0.1.0-preview.2&prerelease
#tool nuget:?package=PouryaKit.Domain&version=0.1.0-preview.2&prerelease

PouryaKit.Domain
The plain types your aggregates are made of. An aggregate derives from AggregateRoot<TId> and is keyed by a typed ID, a behaviour that can fail checks its business rules and returns a Result with a value or an Error for an expected business failure, and what happened is raised as a Domain Event. The package has no dependencies, so it adds nothing to your domain but these types.
Install
dotnet add package PouryaKit.Domain --prerelease
When to use it
- You are writing an aggregate, an entity or the typed ID that keys it.
- A business rule decides whether a change may happen.
- Something in the domain happened that other code reacts to: a Domain Event.
- You are declaring the Errors of a Business Area.
- A business rule compares with the current time, or a test fixes the time a Domain Event records.
A Module's handlers return these types through PouryaKit.Cqrs, and PouryaKit.Persistence.Postgres stores its aggregates.
Quick start
There is nothing to register. A behaviour checks its rule, returns an Error for a business failure and raises a Domain Event on success, as the Proving Sample's Product does:
public static Result<Product> Create(
ProductId id,
CategoryId categoryId,
string name,
string tenant
)
{
ArgumentNullException.ThrowIfNull(id);
ArgumentNullException.ThrowIfNull(categoryId);
ArgumentException.ThrowIfNullOrWhiteSpace(tenant);
if (string.IsNullOrWhiteSpace(name))
{
return ProductErrors.NameRequired;
}
var product = new Product
{
Id = id,
Tenant = tenant,
CategoryId = categoryId,
Name = name.Trim(),
};
product.Raise(new ProductCreatedDomainEvent(id, categoryId, product.Name));
return product;
}
What you get
ResultandError: a value on success, one or more named Errors on failure.- Typed IDs: one sealed record per aggregate, over a
Guid,long,intorstring, so the compiler refuses one aggregate's ID where another's belongs. - Domain Events raised by the aggregate, for the Unit of Work to run.
- Opt-in markers for audit and soft delete, whose fields the Unit of Work sets, and for a tenant's aggregates.
DomainClock, the time a Domain Event records, which a test can fix. A business rule that compares with now takes the time as a parameter.
Return an Error for anything an Actor can cause, such as a missing name. Exceptions are for bugs and infrastructure. Never set an aggregate's Version or clear its Domain Events: the Unit of Work owns both.
Learn more
| 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 PouryaKit.Domain:
| Package | Downloads |
|---|---|
|
PouryaKit.Cqrs
Commands and queries that run as Operations through one fixed pipeline, each Feature with one handler that returns a Result. |
|
|
PouryaKit.Persistence
The repository and Unit of Work contracts Feature code is written against, with their Errors, so a handler never saves or commits. |
|
|
PouryaKit.Messaging
The contracts Feature code reacts and publishes with: Notification Handlers, Integration Events and their handlers, Snapshot mappers and wire names. |
|
|
PouryaKit.Storage
One file storage contract for Feature code: upload, download, delete and presigned links, each returning a Result, with no cloud SDK in a Module. |
|
|
PouryaKit.Reporting
A Module's report laid out once and rendered in memory to a PDF, a CSV file or a spreadsheet, with a logo, an accent colour and an embedded font. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.2 | 208 | 11/1/2026 |
| 0.1.0-preview.1 | 243 | 10/31/2026 |
| 0.1.0-preview.0.28 | 215 | 10/26/2026 |