JCode.ORMX.DbProvider.PostgreSQL
1.2.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package JCode.ORMX.DbProvider.PostgreSQL --version 1.2.2
NuGet\Install-Package JCode.ORMX.DbProvider.PostgreSQL -Version 1.2.2
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="JCode.ORMX.DbProvider.PostgreSQL" Version="1.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JCode.ORMX.DbProvider.PostgreSQL" Version="1.2.2" />
<PackageReference Include="JCode.ORMX.DbProvider.PostgreSQL" />
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 JCode.ORMX.DbProvider.PostgreSQL --version 1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JCode.ORMX.DbProvider.PostgreSQL, 1.2.2"
#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 JCode.ORMX.DbProvider.PostgreSQL@1.2.2
#: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=JCode.ORMX.DbProvider.PostgreSQL&version=1.2.2
#tool nuget:?package=JCode.ORMX.DbProvider.PostgreSQL&version=1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JCode.ORMX.DbProvider.PostgreSQL
PostgreSQL 数据库提供程序,用于 JCode.ORMX 框架。
快速开始
安装
Install-Package JCode.ORMX.DbProvider.PostgreSQL
基本用法
using JCode.ORMX.DbProvider.PostgreSQL;
using JCode.ORMX.Attributes;
// 定义实体
[Table("Users")]
public class User
{
[Column(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
[Column]
public string Name { get; set; }
[Column]
public string Email { get; set; }
}
// 初始化
using var provider = new PostgreSQLProvider("Host=localhost;Database=MyDb;Username=postgres;Password=your_password;");
var tableManager = provider.GetTableManager();
// 创建表
tableManager.Create(typeof(User));
// CRUD 操作
var table = tableManager.Table<User>();
// 插入
var user = table.Insert(new User { Name = "John", Email = "john@example.com" });
// 查询
var users = table.Where(u => u.Name == "John").GetList();
// 更新
table.Update(u => u.Email, "newemail@example.com");
// 删除指定实体
table.Delete(user);
// 或使用条件删除
table.Where(u => u.Id == 1).Delete();
功能特性
- ✅ 完整的 PostgreSQL 支持
- ✅ 类型安全的 LINQ 查询
- ✅ 事务支持
- ✅ 批量操作(InsertAll/UpdateAll/DeleteAll)
- ✅ JSON/JSONB 类型支持
- ✅ 数组类型支持
- ✅ 全文搜索支持
- ✅ 参数化查询(防 SQL 注入)
- ✅ 智能 SQL 调试
链式查询
ORMX 提供流畅的链式查询 API:
// 复杂查询
var result = table
.Where(u => u.Age > 18)
.OrderByDesc(u => u.CreatedAt)
.Limit(10)
.GetList();
// 聚合查询
var count = table.Count();
var maxAge = table.Max(u => u.Age);
SQL 调试
// 查看生成的 SQL
table.Extension((extObj) =>
{
Console.WriteLine($"SQL: {extObj.Query}");
Console.WriteLine($"参数:{string.Join(", ", extObj.Parameters)}");
})
.Where(u => u.Age > 25)
.GetList();
特殊功能
JSON 类型支持
[Table("Products")]
public class Product
{
[Column]
public Dictionary<string, object> Attributes { get; set; } // JSONB 类型
}
var products = table.Where(p => p.Attributes["color"] == "red").GetList();
数组类型支持
[Table("Articles")]
public class Article
{
[Column]
public string[] Tags { get; set; } // 数组类型
}
var articles = table.Where(a => a.Tags.Contains("technology")).GetList();
📖 完整手册
详细使用文档请访问:ORMX 完整使用手册
手册包含:
- 高级查询(聚合、连接、子查询、分组)
- 事务管理最佳实践
- Redis 缓存集成
- 分布式数据库支持(分片、读写分离)
- 性能优化建议
- 完整 API 参考
- 故障排除指南
依赖项
- Npgsql (6.x+)
- JCode.ORMX (1.0.0+)
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- JCode.ORMX (>= 1.2.2)
- Npgsql (>= 8.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.