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
                    
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="Flowsy.Db.Unity" Version="6.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Flowsy.Db.Unity" Version="6.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Flowsy.Db.Unity" />
                    
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 Flowsy.Db.Unity --version 6.0.0
                    
#r "nuget: Flowsy.Db.Unity, 6.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 Flowsy.Db.Unity@6.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=Flowsy.Db.Unity&version=6.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Flowsy.Db.Unity&version=6.0.0
                    
Install as a Cake Tool

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>, and QuerySingle*Async<T> read rows.
  • ExecuteAsync and ExecuteRoutineAsync run commands and routines.
  • QueryMultipleAsync processes multiple result sets; callback overloads keep the reader lifetime safe.
  • StreamAsync<T> returns rows progressively as IAsyncEnumerable<T>.
  • WithSettingsAsync applies scoped session settings and restores their previous values afterward.
  • WithConnectionAsync provides controlled access to the native connection for exceptional provider-specific work.
  • ExecuteScriptAsync and MigrateAsync run 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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