Anarchy.Toolkit.Core.Persistence.Abstractions
Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Core · Package catalog
Persistence contracts for applications that should not depend on a particular database provider.
dotnet add package Anarchy.Toolkit.Core.Persistence.Abstractions
- Use the unit-of-work and async-local flow-context contracts to coordinate persistence operations.
- Define repositories against the supplied repository and storage-policy abstractions and exceptions.
- Choose a concrete provider from the toolkit’s relational adapters or implement your own.
When to use it
Reference this package from application and domain-facing code that needs repository or transaction contracts but should not depend on a database driver. It defines boundaries, not a connection pool, SQL implementation or database schema.
How to use it
- Define application-specific repository interfaces and expose only the operations your use cases need. Implement them in an infrastructure project using the supplied reader, writer or batch contracts where appropriate.
- Let a UseCase own a managed session with
RunInManagedSessionAsync. An Aggregate that must also work alone can useRunInJoinedOrManagedSessionAsync; an Aggregate that only participates usesRunInJoinedSessionAsyncand cannot commit or roll back the caller’s transaction. - Use the storage-policy and flow-context contracts when implementing a provider adapter. Pass cancellation tokens through the operation so database work and rollback cleanup follow the unit-of-work contract.
- In the host, register a concrete provider such as
Infrastructure.Persistence.Db.Postgres,Infrastructure.Persistence.Db.OracleorInfrastructure.Persistence.Db.Mysql. Supply connection and resilience options there, not in application code.
Select transaction boundaries deliberately: the abstractions do not provision databases, retry entire business operations or make external side effects transactional.
See the package catalog and database provider guide.
Releases
See the release notes for the complete release history.