DBAClientX.PostgreSql 1.0.15

dotnet add package DBAClientX.PostgreSql --version 1.0.15
                    
NuGet\Install-Package DBAClientX.PostgreSql -Version 1.0.15
                    
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="DBAClientX.PostgreSql" Version="1.0.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DBAClientX.PostgreSql" Version="1.0.15" />
                    
Directory.Packages.props
<PackageReference Include="DBAClientX.PostgreSql" />
                    
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 DBAClientX.PostgreSql --version 1.0.15
                    
#r "nuget: DBAClientX.PostgreSql, 1.0.15"
                    
#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 DBAClientX.PostgreSql@1.0.15
                    
#: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=DBAClientX.PostgreSql&version=1.0.15
                    
Install as a Cake Addin
#tool nuget:?package=DBAClientX.PostgreSql&version=1.0.15
                    
Install as a Cake Tool

DbaClientX.PostgreSql

PostgreSQL provider for DbaClientX. Simple API over Npgsql with streaming, retries, and transactions.

  • Target Frameworks: net472, net8.0, net10.0
  • NuGet: DBAClientX.PostgreSql

Install

dotnet add package DBAClientX.PostgreSql

Quick examples

Execute stored procedure:

var pg = new DBAClientX.PostgreSql();
var result = pg.ExecuteStoredProcedure(
    host: "localhost", database: "app", username: "user", password: "p@ss",
    procedure: "refresh_stats",
    parameters: new Dictionary<string,object?> { ["@days"] = 7 }
);

Stream query (netstandard2.1+/net8.0):

await foreach (DataRow row in pg.QueryStreamAsync(
    host: "localhost", database: "app", username: "user", password: "p@ss",
    query: "SELECT id, name FROM public.users ORDER BY id",
    cancellationToken: ct))
{
    // consume row
}

Typed mapped query:

int idOrdinal = -1;
int nameOrdinal = -1;
var rows = await pg.QueryAsListAsync(
    connectionString: "Host=localhost;Database=app;Username=user;Password=p@ss;SSL Mode=Require",
    query: "SELECT id, name FROM public.users ORDER BY id",
    initialize: row => {
        idOrdinal = row.GetOrdinal("id");
        nameOrdinal = row.GetOrdinal("name");
    },
    map: row => new UserRow(
        Id: row.GetInt32(idOrdinal),
        Name: row.IsDBNull(nameOrdinal) ? null : row.GetString(nameOrdinal)),
    cancellationToken: ct);

For larger result sets, use QueryStreamAsync<T> with the same mapper shape to avoid buffering all rows.

Non-query from a full connection string:

await pg.ExecuteNonQueryAsync(
    connectionString: "Host=localhost;Database=app;Username=user;Password=p@ss;SSL Mode=Require",
    query: "UPDATE public.users SET last_seen=NOW() WHERE id=@id",
    parameters: new Dictionary<string, object?> { ["@id"] = 1 },
    cancellationToken: ct);

Scalar from a full connection string:

var count = await pg.ExecuteScalarAsync(
    connectionString: "Host=localhost;Database=app;Username=user;Password=p@ss;SSL Mode=Require",
    query: "SELECT COUNT(*) FROM public.users",
    cancellationToken: ct);

Stored procedure from a full connection string:

var result = await pg.ExecuteStoredProcedureAsync(
    connectionString: "Host=localhost;Database=app;Username=user;Password=p@ss;SSL Mode=Require",
    procedure: "public.refresh_stats",
    parameters: new Dictionary<string, object?> { ["@days"] = 7 },
    cancellationToken: ct);

Estimated query plans

ExplainQueryPlan and ExplainQueryPlanAsync capture one native PostgreSQL estimated plan. Named values are bound through Npgsql:

var plan = await pg.ExplainQueryPlanAsync(
    connectionString: "Host=localhost;Database=app;Username=user;Password=p@ss;SSL Mode=Require",
    query: "SELECT id FROM public.users WHERE id=@id",
    parameters: new Dictionary<string, object?> { ["id"] = 42 },
    cancellationToken: ct);

foreach (var step in plan.Steps)
{
    Console.WriteLine($"{step.Detail}: {step.Schema}.{step.Table}, output={step.Estimates?.OutputRows}");
}

Use parameterTypes with existing NpgsqlDbType values when a null or array needs an explicit type. Bound values record the parameter context; they do not guarantee a particular server plan-cache policy. Positional $1 parameters and scripts are unsupported.

Capture uses EXPLAIN (ANALYZE FALSE, VERBOSE TRUE, COSTS TRUE, FORMAT JSON) on a separate connection and read-only transaction. It leaves active client and ambient transactions alone, ignores command replay settings, honors CommandTimeout and caller cancellation, and attempts rollback and disposal after failure. It requires standard_conforming_strings=on and TLS. Planning can still acquire locks and invoke planner-time functions; read-only protection prevents local database writes, without sandboxing external effects of custom functions.

PostgreSqlQueryPlanParser.Parse(sql, explainJson) imports the same estimated JSON format. Native names retain their spelling and case. Operator IDs are assigned in preorder, with root parent -1. Plan Rows maps to output rows and Total Cost to subtree cost. Rows read, table cardinality and database identity remain unknown when the document does not supply them; parallel estimates are not multiplied. ScanOperations reports access methods. FullScans and QueryPlanAssert remain SQLite-specific and reject PostgreSQL plans.

The reader rejects actual execution counters, duplicate properties and multiple statement plans. Limits are 16,777,216 JSON characters, 128 nesting levels and 4096 operators. Capture accepts one SELECT, WITH, INSERT, UPDATE, DELETE or MERGE statement of at most 1,048,576 characters.

See also

  • Core mapping + invoker: DBAClientX.Core
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. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.15 50 10/15/2026
1.0.14 92 10/12/2026
1.0.13 121 10/12/2026
1.0.12 83 10/10/2026
1.0.11 78 10/10/2026
1.0.10 805 9/30/2026
1.0.9 1,503 9/21/2026
1.0.8 3,902 8/21/2026
0.15.0 133 8/20/2026
0.14.0 485 8/14/2026
0.13.0 573 8/2/2026
0.12.0 126 8/2/2026
0.11.0 1,074 7/12/2026
0.10.0 246 6/28/2026
0.9.0 191 6/21/2026
0.8.0 151 6/20/2026
0.7.0 134 6/19/2026
0.6.0 544 5/25/2026
0.5.0 1,310 4/12/2026
0.4.0 858 4/11/2026
Loading failed