Anarchy.Toolkit.Infrastructure.Persistence.Db 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Anarchy.Toolkit.Infrastructure.Persistence.Db --version 2.0.0
                    
NuGet\Install-Package Anarchy.Toolkit.Infrastructure.Persistence.Db -Version 2.0.0
                    
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="Anarchy.Toolkit.Infrastructure.Persistence.Db" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Anarchy.Toolkit.Infrastructure.Persistence.Db" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Anarchy.Toolkit.Infrastructure.Persistence.Db" />
                    
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 Anarchy.Toolkit.Infrastructure.Persistence.Db --version 2.0.0
                    
#r "nuget: Anarchy.Toolkit.Infrastructure.Persistence.Db, 2.0.0"
                    
#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 Anarchy.Toolkit.Infrastructure.Persistence.Db@2.0.0
                    
#: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=Anarchy.Toolkit.Infrastructure.Persistence.Db&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Anarchy.Toolkit.Infrastructure.Persistence.Db&version=2.0.0
                    
Install as a Cake Tool

Anarchy.Toolkit.Infrastructure.Persistence.Db

Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Infrastructure · Package catalog

Provider-agnostic relational persistence infrastructure for toolkit database adapters.

dotnet add package Anarchy.Toolkit.Infrastructure.Persistence.Db
  • IDbDialect, connection-pool and options bases, unit of work, resilience policy and retry builder provide the common database layer.
  • Build repositories on the reader, writer and batch-writer bases; database health reports use the dialect's health-check SQL.
  • Transactional outbox and event-store contracts, records and repository bases are included. Consumers supply provider-specific concrete repositories and SQL.
  • Use a provider adapter for PostgreSQL, Oracle or MySQL, or implement a new dialect and adapter.

When to use it

Use this package when implementing a relational adapter or shared repository behavior. Most applications should reference a provider-specific adapter instead: this package supplies common policies and base classes but does not choose a driver, provision a schema or provide concrete SQL for an application's tables.

How to use it

  1. Select an existing provider, or implement IDbDialect, connection-string and pool types, a unit of work, retry policy and provider-specific repository bases for a new database.
  2. Derive concrete reader/writer repositories and provide their SQL and mappings. For event-store or outbox functionality, supply the provider-specific concrete repositories and embedded SQL as described in the provider guide.
  3. Configure reader and writer hosts, credentials, command timeout and resilience settings at the host. DbConnectionOptions.MaximumPoolSize defaults to 100 and is applied by the included providers.
  4. Register the provider module and optional health reports, then inject the repository and unit-of-work abstractions into application services. Define transaction and retry boundaries explicitly, especially when an operation has non-database side effects.

A unit-of-work instance rejects nested and concurrent sessions. The code that starts a session owns its transaction: RunInJoinedSessionAsync lets a participant, such as an aggregate called by a UseCase, share the caller's transaction without being able to begin, commit or roll it back (TransactionNotOwnedException), and RunInJoinedOrManagedSessionAsync joins the caller's transaction when there is one and otherwise owns a managed session. BeginAsync, CommitAsync and RollbackAsync only act on the session the instance started in the current async flow.

A transaction is rolled back only when it exists and is still pending, including one a RunInSessionAsync callback left open, and a rolled-back or abandoned transaction publishes RolledBackUowTransactionLocalEvent. Cancellation is observed while connecting, beginning, running the callback and just before an automatic commit, and propagates after rollback and cleanup, which use an uncancelled token; a commit is never interrupted once started. If rollback also fails, inspect the original exception's Data for UnitOfWork.RollbackFailure; if cleanup fails while another exception is already being propagated, inspect that exception's Data for UnitOfWork.CleanupFailure. Connections are discarded after a failed begin, commit, rollback or transaction disposal instead of being returned to the pool. Each session can start only one transaction; further calls to BeginAsync fail with TransactionAlreadyActiveException. If transaction and connection cleanup both fail, the connection failure is available on the transaction failure under UnitOfWork.ConnectionCleanupFailure.

See adding a database provider and the persistence notes, including known limitations.

Releases

2.0.0

  • Preserve the original session failure when transaction startup, rollback or cleanup fails; propagate caller cancellation and reject concurrent sessions.
  • Reject repeated transaction starts and preserve both failures when transaction and connection cleanup fail.
  • Make transaction ownership explicit with RunInJoinedSessionAsync and RunInJoinedOrManagedSessionAsync; participants cannot begin, commit or roll back the caller's transaction.
  • Roll back only pending transactions, explicitly roll back what a RunInSessionAsync callback left open, and stop reporting post-commit notification failures as commit failures.
  • Check cancellation before an automatic commit and never interrupt a started commit; publish transaction lifecycle events with an uncancelled token.
  • Discard the connection after a failed begin or commit, make session cleanup idempotent, and reject BeginAsync, CommitAsync and RollbackAsync calls from other async flows.

1.2.1

  • docs(packages): identify each package's pillar and layer
  • build(packages): attribute the copyright to Leandro Melão Medeiros
  • build: relicense under Apache-2.0 and update the package metadata

1.2.0

  • build(deps): upgrade Swashbuckle.AspNetCore to 11.0.1 and Microsoft.OpenApi to 3.11.1

1.1.5

  • docs: expand XML docblocks across all projects for the DocFX API reference

1.1.4

  • refactor(src): clean up code style across library packages

1.1.2

  • build: migrate local automation to build tooling

1.1.1

  • docs: expand package guides and release histories
  • chore(deps): update AWS, Polly, and xUnit packages

1.1.0

  • Added configurable maximum database connection pool size.

1.0.1

  • Added a package-specific NuGet README.

1.0.0

  • Introduced provider-agnostic relational repositories, units of work, connection configuration, event store support and health reporting.
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.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Anarchy.Toolkit.Infrastructure.Persistence.Db:

Package Downloads
Anarchy.Toolkit.Testing.Db

Provider-agnostic relational database test helpers (DbTestHelper: enum type handlers and table truncate/clear; DbOptionsMapper) for integration tests.

Anarchy.Toolkit.Infrastructure.Persistence.Oracle

Oracle implementation of the relational persistence layer: dialect, connection string, connection pool, Unit of Work, resilience policy, repository bases and service health reports.

Anarchy.Toolkit.Infrastructure.Persistence.Mysql

MySQL relational persistence adapter with connection pools, unit of work, resilience, repository bases and health reports.

Anarchy.Toolkit.Infrastructure.Persistence.Postgres

PostgreSQL implementation of the relational persistence layer: dialect, connection string, connection pool, Unit of Work, resilience policy, repository bases and service health reports.

Anarchy.Toolkit.Infrastructure.Persistence.Db.Mysql

MySQL relational persistence adapter with connection pools, unit of work, resilience, repository bases and health reports.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 0 11/21/2026
2.0.0 0 11/20/2026
1.2.1 114 11/17/2026
1.2.0 97 11/17/2026
1.1.5 144 11/16/2026
1.1.4 183 11/14/2026
1.1.3 191 11/9/2026
1.1.2 143 11/9/2026
1.1.0 161 11/6/2026
1.0.1 154 11/6/2026
1.0.0 162 11/5/2026

Initial release.