StringThing.Npgsql.Dapper
1.0.0
dotnet add package StringThing.Npgsql.Dapper --version 1.0.0
NuGet\Install-Package StringThing.Npgsql.Dapper -Version 1.0.0
<PackageReference Include="StringThing.Npgsql.Dapper" Version="1.0.0" />
<PackageVersion Include="StringThing.Npgsql.Dapper" Version="1.0.0" />
<PackageReference Include="StringThing.Npgsql.Dapper" />
paket add StringThing.Npgsql.Dapper --version 1.0.0
#r "nuget: StringThing.Npgsql.Dapper, 1.0.0"
#:package StringThing.Npgsql.Dapper@1.0.0
#addin nuget:?package=StringThing.Npgsql.Dapper&version=1.0.0
#tool nuget:?package=StringThing.Npgsql.Dapper&version=1.0.0
StringThing.Npgsql.Dapper
Dapper result mapping for StringThing.Npgsql. Injection-safe interpolated SQL on the input side, Dapper mapping on the output side.
Install
dotnet add package StringThing.Npgsql.Dapper
Quick start
var userId = 42;
var user = await connection.QueryStringSingleAsync<User>(
$"SELECT id, name, email FROM users WHERE id = {userId}",
cancellationToken);
Available methods
All methods are extension methods on NpgsqlConnection:
| Method | Returns |
|---|---|
QueryStringAsync<T> |
Task<List<T>> |
QueryStringFirstAsync<T> |
Task<T> |
QueryStringFirstOrDefaultAsync<T> |
Task<T?> |
QueryStringSingleAsync<T> |
Task<T> |
QueryStringSingleOrDefaultAsync<T> |
Task<T?> |
ExecuteStringAsync |
Task<int> |
ExecuteStringScalarAsync<T> |
Task<T?> |
Synchronous variants are also available (without the Async suffix).
Why "String" in the method names?
The method names include String to avoid collision with Dapper's own extension methods. If both were named QueryAsync, a using change could silently switch from the safe StringThing path to Dapper's string-based path — defeating the injection safety guarantee.
QueryStringSingleAsync is unambiguous: it's the StringThing version, always.
DDL and static SQL
For setup queries with no parameters, use $"..." without interpolation:
await connection.ExecuteStringAsync(
$"""
CREATE TABLE IF NOT EXISTS users (
id integer PRIMARY KEY,
name text NOT NULL
)
""",
cancellationToken);
Dapper license
This package bundles Dapper internally for result mapping. Dapper is licensed under the Apache License 2.0, copyright 2019 Stack Exchange, Inc. The bundled Dapper DLL is not exposed as a dependency — consumers do not need a separate Dapper reference.
Built by Immersus Machina
| 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
- StringThing.Npgsql (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.