Flowsy.Db.Unity
6.0.0
dotnet add package Flowsy.Db.Unity --version 6.0.0
NuGet\Install-Package Flowsy.Db.Unity -Version 6.0.0
<PackageReference Include="Flowsy.Db.Unity" Version="6.0.0" />
<PackageVersion Include="Flowsy.Db.Unity" Version="6.0.0" />
<PackageReference Include="Flowsy.Db.Unity" />
paket add Flowsy.Db.Unity --version 6.0.0
#r "nuget: Flowsy.Db.Unity, 6.0.0"
#:package Flowsy.Db.Unity@6.0.0
#addin nuget:?package=Flowsy.Db.Unity&version=6.0.0
#tool nuget:?package=Flowsy.Db.Unity&version=6.0.0
Flowsy.Db.Unity
Provider-neutral SQL data access for .NET 8 and .NET 10, built on Dapper and Evolve. It provides keyed connections, scoped sessions, naming conventions, routines, transactions, migrations, logging, tracing, and metrics without coupling application code to a specific database driver.
Install
dotnet add package Flowsy.Db.Unity
Install a provider driver separately. For PostgreSQL, prefer the companion package:
dotnet add package Flowsy.Db.Unity.Postgres
Quick Start
Register a connection once during application startup. Connection keys and anonymous-object properties use PascalCase; conventions translate them for the database.
using Flowsy.Db.Unity;
using Flowsy.Db.Unity.Postgres;
services.AddDatabases(options =>
{
options
.UsePostgres("Catalog", connectionString)
.AsDefault()
.WithConventions()
.ForParameters(prefix: "p_", useNamedParameters: true)
.WithDefault(DbCaseStyle.LowerSnakeCase);
});
Inject the scoped IDbConnectionHub, create a session, and dispose the session after use:
public sealed class ProductReader(IDbConnectionHub connectionHub)
{
public async Task<Product?> FindAsync(Guid productId, CancellationToken cancellationToken)
{
await using var db = await connectionHub.CreateSessionAsync(cancellationToken);
return await db.QuerySingleOrDefaultAsync<Product>(
"select product_id, name, price from catalog.product where product_id = @p_product_id",
new { ProductId = productId },
cancellationToken);
}
}
QueryFirst* requires at least one row. QuerySingle* rejects more than one row. The OrDefault variants allow an empty result.
Transactions
Use the callback helper to commit on success and roll back on failure:
await db.InTransactionAsync(async (session, ct) =>
{
await session.ExecuteAsync(
"update inventory set available = available - @p_quantity where product_id = @p_product_id",
new { ProductId = productId, Quantity = quantity },
ct);
}, cancellationToken);
Connections configured with RequireTransactionForWrites reject detected writes outside a transaction. Exceptions can be configured for statements that are safe in your environment.
Common Operations
QueryAsync<T>,QueryFirst*Async<T>, andQuerySingle*Async<T>read rows.ExecuteAsyncandExecuteRoutineAsyncrun commands and routines.QueryMultipleAsyncprocesses multiple result sets; callback overloads keep the reader lifetime safe.StreamAsync<T>returns rows progressively asIAsyncEnumerable<T>.WithSettingsAsyncapplies scoped session settings and restores their previous values afterward.WithConnectionAsyncprovides controlled access to the native connection for exceptional provider-specific work.ExecuteScriptAsyncandMigrateAsyncrun scripts and Evolve migrations.
Per-call DbSessionCallOptions can override timeout, command type, and Dapper flags without changing the connection configuration.
Conventions and Mapping
DbConventionSet controls routine, parameter, enum, date-time, and command behavior. Register result types with MapTypes when database column names use a different case style. Parameter mappings and enum member mappings provide explicit exceptions when a general convention is not enough. Built-in Dapper handlers support DateOnly and TimeOnly.
Observability
Operations emit structured logs with session and operation identifiers. DbDiagnostics exposes ActivitySource traces and Meter metrics for command duration, errors, opened connections, and slow operations.
Learn More
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- CaseON (>= 1.4.0)
- Dapper (>= 2.1.79)
- Evolve (>= 3.2.0)
- Microsoft.Extensions.Configuration (>= 10.0.8)
- Microsoft.Extensions.Configuration.Json (>= 10.0.8)
- Microsoft.Extensions.Hosting (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Ulid (>= 1.4.1)
-
net8.0
- CaseON (>= 1.4.0)
- Dapper (>= 2.1.79)
- Evolve (>= 3.2.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Hosting (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Ulid (>= 1.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Flowsy.Db.Unity:
| Package | Downloads |
|---|---|
|
Flowsy.Db.Unity.Postgres
PostgreSQL provider integration for Flowsy.Db.Unity. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.0 | 124 | 9/29/2026 |
| 5.0.0 | 149 | 6/8/2026 |
| 4.0.4 | 234 | 11/15/2025 |
| 4.0.3 | 242 | 9/25/2025 |
| 4.0.2 | 247 | 9/25/2025 |
| 4.0.1 | 249 | 9/24/2025 |
| 4.0.0 | 296 | 9/14/2025 |
| 3.0.0 | 400 | 6/12/2025 |
| 2.0.5 | 364 | 6/9/2025 |
| 2.0.4 | 385 | 6/9/2025 |
| 2.0.3 | 368 | 6/9/2025 |
| 2.0.2 | 367 | 6/9/2025 |
| 2.0.1 | 180 | 6/6/2025 |
| 2.0.0 | 236 | 6/1/2025 |
| 1.2.1 | 249 | 6/1/2025 |
| 1.2.0 | 185 | 5/25/2025 |
| 1.1.0 | 184 | 5/25/2025 |
| 1.0.0 | 210 | 5/18/2025 |