Anarchy.Toolkit.Infrastructure.Persistence.Db
2.0.0
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
<PackageReference Include="Anarchy.Toolkit.Infrastructure.Persistence.Db" Version="2.0.0" />
<PackageVersion Include="Anarchy.Toolkit.Infrastructure.Persistence.Db" Version="2.0.0" />
<PackageReference Include="Anarchy.Toolkit.Infrastructure.Persistence.Db" />
paket add Anarchy.Toolkit.Infrastructure.Persistence.Db --version 2.0.0
#r "nuget: Anarchy.Toolkit.Infrastructure.Persistence.Db, 2.0.0"
#:package Anarchy.Toolkit.Infrastructure.Persistence.Db@2.0.0
#addin nuget:?package=Anarchy.Toolkit.Infrastructure.Persistence.Db&version=2.0.0
#tool nuget:?package=Anarchy.Toolkit.Infrastructure.Persistence.Db&version=2.0.0
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
- 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. - 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.
- Configure reader and writer hosts, credentials, command timeout and resilience settings at the host.
DbConnectionOptions.MaximumPoolSizedefaults to 100 and is applied by the included providers. - 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
RunInJoinedSessionAsyncandRunInJoinedOrManagedSessionAsync; participants cannot begin, commit or roll back the caller's transaction. - Roll back only pending transactions, explicitly roll back what a
RunInSessionAsynccallback 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,CommitAsyncandRollbackAsynccalls 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 | 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
- Anarchy.Toolkit.Core (>= 2.0.0)
- Anarchy.Toolkit.Core.Events (>= 2.0.0)
- Anarchy.Toolkit.Core.Health (>= 2.0.0)
- Anarchy.Toolkit.Core.Persistence.Abstractions (>= 2.0.0)
- Anarchy.Toolkit.Core.Telemetry (>= 1.0.0)
- Dapper (= 2.1.79)
- Humanizer (>= 3.0.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.15)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Diagnostics (>= 10.0.15)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Logging (>= 10.0.15)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.15)
- Newtonsoft.Json (>= 13.0.4)
- Polly.Core (>= 8.9.1)
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.
Initial release.