CodeQuery.Postgres
1.0.0-preview.12
See the version list below for details.
dotnet add package CodeQuery.Postgres --version 1.0.0-preview.12
NuGet\Install-Package CodeQuery.Postgres -Version 1.0.0-preview.12
<PackageReference Include="CodeQuery.Postgres" Version="1.0.0-preview.12" />
<PackageVersion Include="CodeQuery.Postgres" Version="1.0.0-preview.12" />
<PackageReference Include="CodeQuery.Postgres" />
paket add CodeQuery.Postgres --version 1.0.0-preview.12
#r "nuget: CodeQuery.Postgres, 1.0.0-preview.12"
#:package CodeQuery.Postgres@1.0.0-preview.12
#addin nuget:?package=CodeQuery.Postgres&version=1.0.0-preview.12&prerelease
#tool nuget:?package=CodeQuery.Postgres&version=1.0.0-preview.12&prerelease
CodeQuery
Write type-safe, robust SQL in C#. The bridge between SQL and C#.
CodeQuery is a .NET Standard 2.1 library for expressing queries, schema, migrations and routines through the C# type system. It stays as close to SQL as possible while letting the compiler check every column and table reference — so a rename refactors your queries instead of breaking them at runtime.
Install
Add the core package and the driver for your database:
dotnet add package CodeQuery
dotnet add package CodeQuery.Sqlite # or CodeQuery.Postgres / CodeQuery.MySql / CodeQuery.Mssql
| Package | Database |
|---|---|
CodeQuery |
Core library (required) |
CodeQuery.Postgres |
PostgreSQL, over Npgsql — including the PostGIS, TimescaleDB and pg_trgm extensions |
CodeQuery.Sqlite |
SQLite, over Microsoft.Data.Sqlite |
CodeQuery.MySql |
MySQL and MariaDB, over MySqlConnector |
CodeQuery.Mssql |
Microsoft SQL Server, over System.Data.SqlClient |
CodeQuery.EntityFramework |
Query the tables an existing EF Core DbContext already maps |
Define a schema
Declare your database as a class — one member per database object, each member constructing itself — and let CodeQuery inspect the entity types:
public class AppDb : IDbSchema
{
// tables — the shape comes from the entity type, the rest travels with the member
public DbTable<Author> Authors => new();
public DbTable<Book> Books => new(b => b.Column(x => x.Price).Check(p => p >= 0));
// views, stored procedures and functions are the objects you hand back, nothing inferred
public DbView<ExpensiveBook> Expensive => new ExpensiveBooksView();
}
var db = DatabaseInitializer.Build<AppDb>(configuration);
Query
var books = db.From<Book>()
.InnerJoin(Author.On(), b => b.AuthorId)
.Select((b, a) => new { b.Title, a.Name })
.Fetch();
The property references are compiler-checked and refactor-safe — there are no SQL strings in the query.
Strong typing
Strong typing is the core principle. Schema constraints, defaults and partition bounds are expressed as typed CLR values and expression trees, never as SQL fragments:
// The check is an expression; the compiler validates the column and the comparison.
productTable.HasCheck("CK_Products_Price", r => r.Price >= 0);
// The partition key is an expression; the range bounds follow the key's type.
config.PartitionBy(s => s.LogDate)
.AsRange()
.Add("y2024", new DateTime(2024, 1, 1), new DateTime(2025, 1, 1));
Documentation
Full guides — queries, joins, aggregates, CTEs, window functions, migrations, views, stored
procedures, full-text search and dialect support — live in the Web/ documentation site.
License
| 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 was computed. |
| .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. |
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.0-preview.16 | 125 | 8/31/2026 |
| 1.0.0-preview.15 | 60 | 8/29/2026 |
| 1.0.0-preview.13 | 62 | 8/28/2026 |
| 1.0.0-preview.12 | 73 | 8/27/2026 |
| 1.0.0-preview.11 | 66 | 8/27/2026 |
| 1.0.0-preview.10 | 75 | 8/27/2026 |
| 1.0.0-preview.9 | 80 | 8/25/2026 |
| 1.0.0-preview.8 | 68 | 8/24/2026 |
| 1.0.0-preview.7 | 154 | 8/24/2026 |
| 1.0.0-preview.6 | 72 | 8/22/2026 |
| 1.0.0-preview.5 | 61 | 8/19/2026 |
| 1.0.0-preview.4 | 70 | 8/17/2026 |
| 1.0.0-preview.3 | 60 | 8/17/2026 |
| 1.0.0-preview.2 | 73 | 8/13/2026 |
| 1.0.0-preview.1 | 74 | 8/4/2026 |