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

PouryaKit.Persistence
The contracts Feature code reaches its data through. A handler loads and adds aggregates with IRepository<TAggregate, TId> and returns, and the Unit of Work, which a write model package supplies, keeps everything the Operation changed together or discards it together. UnitOfWorkErrors names what a commit can answer, and IUnitOfWorkConnection lets a command write a Module-internal table in plain SQL inside that same Unit of Work.
Install
dotnet add package PouryaKit.Persistence --prerelease
When to use it
- You are reading and changing an aggregate through the repository and a specification.
- A command writes a projection, a tally or a copy that no aggregate maps.
- You handle a concurrent change as an Error.
A Module references PouryaKit.Persistence.Postgres, which brings this package and PouryaKit.Persistence.EFCore. PouryaKit.Persistence.Marten is the other write model, and PouryaKit.Persistence.Dapper serves reads for display.
Quick start
There is nothing to register here: the Module's write model fills these contracts. Inject the repository, change the aggregate and return its Result, as the Proving Sample does:
internal sealed class RenameProductCommandHandler(IRepository<Product, ProductId> products)
: CommandHandler<RenameProductCommand>
{
public override async Task<Result> Handle(
RenameProductCommand command,
CancellationToken cancellationToken
)
{
var product = await products.FindAsync(new ProductId(command.ProductId), cancellationToken);
return product is null ? ProductErrors.NotFound : product.Rename(command.Name);
}
}
What you get
- A generic repository with specifications, and nothing on it saves.
UnitOfWorkErrors, so a commit that cannot go through is an Error, not an exception.- A plain-SQL write that commits or rolls back with the Operation, through
IUnitOfWorkConnection.
Nothing in a Module saves or commits. Feature code never calls SaveChanges and never opens a transaction, and a structure test rejects a Module that does.
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
- Ardalis.Specification (>= 9.3.1)
- PouryaKit.Domain (>= 0.1.0-preview.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on PouryaKit.Persistence:
| Package | Downloads |
|---|---|
|
PouryaKit.Persistence.EFCore
The EF Core Unit of Work: a DbContext per Module that saves and commits each Operation once, with the repository, audit, soft delete and conflicts as Errors. |
|
|
PouryaKit.Persistence.Marten
Streams on Marten over PostgreSQL: aggregates stored as the events they appended, loaded by folding them, with a Unit of Work of their own. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.2 | 108 | 11/1/2026 |
| 0.1.0-preview.1 | 113 | 10/31/2026 |
| 0.1.0-preview.0.28 | 111 | 10/26/2026 |