Net4x.DapperLibrary.Postgres
1.9.9
dotnet add package Net4x.DapperLibrary.Postgres --version 1.9.9
NuGet\Install-Package Net4x.DapperLibrary.Postgres -Version 1.9.9
<PackageReference Include="Net4x.DapperLibrary.Postgres" Version="1.9.9" />
<PackageVersion Include="Net4x.DapperLibrary.Postgres" Version="1.9.9" />
<PackageReference Include="Net4x.DapperLibrary.Postgres" />
paket add Net4x.DapperLibrary.Postgres --version 1.9.9
#r "nuget: Net4x.DapperLibrary.Postgres, 1.9.9"
#:package Net4x.DapperLibrary.Postgres@1.9.9
#addin nuget:?package=Net4x.DapperLibrary.Postgres&version=1.9.9
#tool nuget:?package=Net4x.DapperLibrary.Postgres&version=1.9.9
DapperLibrary.Postgres
PostgreSQL provider integration for DapperLibrary. This project supplies a Postgres-specific DapperContext implementation, a provider factory backed by Npgsql, and Postgres-specific database model and type mappings.
Purpose
Provide PostgreSQL engine-specific behavior while preserving the common DapperLibrary API. This includes:
PostgresDapperContext� aDapperContextconfigured for Npgsql withUse/UseOncehelpers.NpgsqlProviderFactory� configures parameter handling and adapter events for the Npgsql provider.PostgresDatabaseModel,PostgresDatabaseModelTypesandPostgresDatabaseEnumTypes� identifier delimiters, statement terminator, parameter naming and SQL type mappings for PostgreSQL.
Key types
PostgresDapperContext- Derives from
DapperContextand initializes the context withNpgsqlProviderFactoryand configuration fromDapperConfigurationManager. - Static helpers
Use,Use(IContextCreator),Use(string, string)andUseOnceintegrate withDapperContextFactoryand set common Postgres defaults (for example identity initializer and datetime formatting). - When used via
Usehelpers, contexts are configured with:DatabaseModel.IdentityInitializer = "GENERATED ALWAYS AS IDENTITY"DatabaseModel.FormatDatetimeAsString = dateTime => $"TIMESTAMP '{dateTime:yyyy-MM-dd HH:mm:ss.fff}'"
- Derives from
NpgsqlProviderFactory- Inherits from
ProviderFactoryBaseand usesNpgsqlFactory.Instanceas the underlying provider. - Sets
ParameterModel.ParameterPrefix = "@"andParameterModel.AddIndex = trueand installs aPrepareCommandParametersdelegate. - Attaches
RowUpdating/RowUpdatedhandlers to data adapters and exposes hooks to forward these events.
- Inherits from
PostgresDatabaseModeland related types- Identifier delimiters:
"(double-quote). - Statement terminator:
;. - Parameter prefix:
@and parameter base name:Par. - Type mappings reflect PostgreSQL types:
uuid,jsonb,timestamptz,bytea,numeric,double precision,integer,bigint,boolean, etc.
- Identifier delimiters:
Usage examples
Create and use a Postgres context directly:
using var context = new PostgresDapperContext();
// use context.Operations / context.Schema / context.SaveDataTable etc.
Register a context creator in bootstrap code:
PostgresDapperContext.Use();
// or bind an explicit connection string and provider name
PostgresDapperContext.UseOnce(connectionString, providerName);
When creating contexts via the static helpers, the database model will be pre-configured with Postgres-friendly defaults for identity columns and datetime literal formatting.
Multi-targeting & compatibility
- The project is built to be compatible with .NET Standard (the current build artifacts are produced for .NET Standard targets in this repository). Consumer projects targeting modern .NET (5/6/8/10) or .NET Framework should reference the matching compiled asset from the package.
- Conditional compilation and provider selection logic in the wider solution ensure the appropriate ADO.NET provider (Npgsql) is referenced for the target framework used by the consumer.
Synchronous vs asynchronous behavior
- PostgreSQL (Npgsql) offers robust async I/O support. DapperLibrary exposes both synchronous and asynchronous variants for most operations (
GetDataReaderAsync,GetDataTableAsync,SetDataAsync,QueryAsync<T>, etc.). - Prefer the
Async-suffixed methods in server and I/O-bound applications to avoid blocking threads. The library uses async provider APIs where available and falls back to synchronous flows on frameworks/providers that lack Task-based ADO.NET async support.
Events and data adapter behavior
NpgsqlProviderFactory.CreateDataAdapterwiresRowUpdatedandRowUpdatingevents coming fromNpgsqlDataAdapterand forwards them via the provider factory. This enables consumer code to hook into theDbDataAdapterrow lifecycle when usingSaveDataTableand related adapter-based persistence.
Notes and best practices
- Use
WithConnectionoverloads when executing operations against a different named connection for a single call to avoid race conditions aroundConnectionStringToRead. - Prefer
Use/UseOncehelpers to ensure consistent Postgres configuration across created contexts. - Rely on the schema helpers (
IDapperContext.Schema) and cached metadata for efficient schema inspection.
For implementation details, consult the source files under DbContexts and the NpgsqlProviderFactory class.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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 Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Azure.Identity (>= 1.13.1)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Npgsql (>= 8.0.8)
- System.Configuration.ConfigurationManager (>= 9.0.0)
-
.NETStandard 2.1
- Azure.Identity (>= 1.13.1)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Npgsql (>= 8.0.8)
- System.Configuration.ConfigurationManager (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Net4x.DapperLibrary.Postgres:
| Package | Downloads |
|---|---|
|
Net4x.DapperLibrary.Docker
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.9.9 | 25 | 12/22/2025 |
| 1.6.0.12 | 237 | 12/12/2025 |
| 1.6.0.11 | 206 | 12/12/2025 |
| 1.6.0.10 | 533 | 12/9/2025 |
| 1.6.0.9 | 180 | 12/4/2025 |
| 1.6.0.8 | 190 | 12/4/2025 |
| 1.6.0.7 | 246 | 11/30/2025 |
| 1.6.0.6 | 167 | 11/27/2025 |
| 1.6.0.5 | 219 | 11/22/2025 |
| 1.6.0.4 | 133 | 11/16/2025 |
| 1.6.0.3 | 168 | 11/15/2025 |
| 1.6.0.2 | 258 | 11/14/2025 |
| 1.6.0.1 | 229 | 11/10/2025 |
| 1.6.0 | 194 | 11/9/2025 |
| 1.5.0.3 | 176 | 11/5/2025 |
| 1.5.0.2 | 183 | 11/3/2025 |
| 1.5.0.1 | 184 | 11/3/2025 |
| 1.5.0 | 136 | 10/26/2025 |
| 1.4.1.6 | 162 | 10/24/2025 |
| 1.4.1.5 | 181 | 10/22/2025 |
| 1.4.1.4 | 197 | 10/22/2025 |