Socigy.OpenSource.DB
0.1.83
See the version list below for details.
dotnet add package Socigy.OpenSource.DB --version 0.1.83
NuGet\Install-Package Socigy.OpenSource.DB -Version 0.1.83
<PackageReference Include="Socigy.OpenSource.DB" Version="0.1.83" />
<PackageVersion Include="Socigy.OpenSource.DB" Version="0.1.83" />
<PackageReference Include="Socigy.OpenSource.DB" />
paket add Socigy.OpenSource.DB --version 0.1.83
#r "nuget: Socigy.OpenSource.DB, 0.1.83"
#:package Socigy.OpenSource.DB@0.1.83
#addin nuget:?package=Socigy.OpenSource.DB&version=0.1.83
#tool nuget:?package=Socigy.OpenSource.DB&version=0.1.83
Socigy.OpenSource.DB
A Roslyn incremental source generator that reads your annotated C# classes at build time and emits a fully typed PostgreSQL data layer — INSERT, SELECT, UPDATE, DELETE, JOINs, set operations, and migrations — without a single line of boilerplate.
Full documentation → docs.socigy.com/database
Installation
dotnet add package Socigy.OpenSource.DB
A single package reference installs the Core runtime, the Roslyn source generator, and the CLI migration tool.
Quick start
1. Annotate a class
using Socigy.OpenSource.DB.Attributes;
[Table("users")]
public partial class User
{
[PrimaryKey, Default(DbDefaults.Guid.Random)]
public Guid Id { get; set; }
[StringLength(3, 50), Unique]
public string Username { get; set; }
[StringLength(5, 254), Unique]
public string Email { get; set; }
public string Status { get; set; } = "active"; // → DEFAULT 'active'
[Default(DbDefaults.Time.Now)]
public DateTime CreatedAt { get; set; }
}
2. Build — the generator emits all query methods
dotnet build
3. Use the generated methods
// INSERT
var user = new User { Username = "alice", Email = "alice@example.com" };
await user.Insert()
.WithConnection(conn)
.ExcludeAutoFields() // let the DB fill Id and CreatedAt
.WithValuePropagation() // write DB-generated values back to the object
.ExecuteAsync();
// SELECT
await foreach (var u in User.Query(x => x.Status == "active")
.OrderBy(x => new object[] { x.CreatedAt })
.Limit(20)
.WithConnection(conn)
.ExecuteAsync())
{
Console.WriteLine(u.Username);
}
// UPDATE
user.Email = "newalice@example.com";
await user.Update()
.WithConnection(conn)
.WithFields(x => new object[] { x.Email })
.ExecuteAsync();
// DELETE
await user.Delete().WithConnection(conn).ExecuteAsync();
Features
- Zero boilerplate — annotate once, every CRUD method is generated at build time
- Fully typed — WHERE clauses, ORDER BY, and field selectors use C# expressions; no raw strings
- Migrations — CLI tool analyses your compiled assembly and generates PostgreSQL DDL; a tracking table handles incremental applies
- JOINs —
Join,LeftJoin,RightJoin,FullOuterJoin,NaturalJoin,CrossJoin - Set operations —
Union,UnionAll,Intersect,IntersectAll,Except,ExceptAll - Flagged enums —
[FlaggedEnum]generates a junction table and typed flag helpers - JSON columns —
[JsonColumn]and[RawJsonColumn]for JSONB with optional AOT-safe typed serialisation - Procedure mapping — write SQL in
.sqlfiles, get strongly-typed async wrappers at compile time - Value convertors — custom per-column read/write transformation via
IDbValueConvertor<T> - AOT compatible — no runtime reflection; safe to publish with
PublishAot=true
DI setup
Add socigy.json to your DB class library project root:
{
"database": {
"platform": "postgresql",
"databaseName": "MyDb",
"generateDbConnectionFactory": true,
"generateWebAppExtensions": true
}
}
The build generates AddMyDb() extension methods and registers IDbConnectionFactory and IMigrationManager in DI:
// Program.cs
builder.AddMyDb();
var app = builder.Build();
await app.EnsureLatestMyDbMigration(); // apply pending migrations on startup
Connection strings are read from appsettings.json:
{
"ConnectionStrings": {
"MyDb": {
"Default": "Host=localhost;Port=5432;Username=postgres;Password=secret"
}
}
}
Migrations
Run the migration build configuration to generate DDL from your current model:
dotnet build -c DB_Migration
Migration files land in Socigy/Migrations/. Apply them at startup with EnsureLatestMyDbMigration() or manage them manually via IMigrationManager.EnsureLatestVersion().
Documentation
Full reference covering every attribute, builder method, join variant, migration option, and DI pattern:
| Section | Topics |
|---|---|
| Getting started | Installation, project structure, socigy.json |
| Defining models | All attributes, column types, defaults, constraints |
| Querying | SELECT, INSERT, UPDATE, DELETE, JOINs, set operations |
| Migrations | CLI tool, schema generation, applying, custom migrations |
| Advanced | Procedure mapping, value convertors, Check DSL |
License
MIT License with Non-Commercial and Graphic Attribution Clauses — see 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. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Socigy.OpenSource.DB:
| Package | Downloads |
|---|---|
|
Socigy.OpenSource.DB.HashiCorp
Optional HashiCorp Vault / OpenBao integration for Socigy.OpenSource.DB: field encryption (KV-v2 key, Transit data-key envelope with key rotation, or Transit EaaS-direct) and rotating DB credentials (Database secrets engine). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.8 | 367 | 9/9/2026 |
| 0.3.7 | 203 | 7/28/2026 |
| 0.3.6 | 303 | 7/17/2026 |
| 0.3.5 | 289 | 6/27/2026 |
| 0.3.4 | 173 | 6/26/2026 |
| 0.3.3 | 181 | 6/26/2026 |
| 0.3.2 | 183 | 6/6/2026 |
| 0.3.1 | 177 | 6/5/2026 |
| 0.3.0 | 169 | 6/5/2026 |
| 0.2.0 | 133 | 6/5/2026 |
| 0.1.83 | 154 | 5/3/2026 |
| 0.1.82 | 140 | 5/3/2026 |
| 0.1.81 | 141 | 5/2/2026 |
| 0.1.80 | 121 | 5/2/2026 |
| 0.1.79 | 131 | 5/1/2026 |
| 0.1.78 | 121 | 5/1/2026 |
| 0.1.77 | 149 | 4/29/2026 |
| 0.1.76 | 135 | 4/25/2026 |
| 0.1.75 | 129 | 4/25/2026 |
| 0.1.74 | 125 | 4/24/2026 |