Smart.Data.Npgsql
3.0.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 Smart.Data.Npgsql --version 3.0.2
NuGet\Install-Package Smart.Data.Npgsql -Version 3.0.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="Smart.Data.Npgsql" Version="3.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Smart.Data.Npgsql" Version="3.0.2" />
<PackageReference Include="Smart.Data.Npgsql" />
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 Smart.Data.Npgsql --version 3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Smart.Data.Npgsql, 3.0.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.
#addin nuget:?package=Smart.Data.Npgsql&version=3.0.2
#tool nuget:?package=Smart.Data.Npgsql&version=3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Smart.Data.Npgsql
基于 Npgsql 封装的轻量级 PostgreSQL 数据库操作库,支持 .NET 6/8/9。
功能特性
- 异步数据库操作(增删改查)
- 自动连接管理
- 事务批处理支持
- DI 友好设计
- 参数化查询防护
安装
bash
dotnet add package Smart.Data.Npgsql
快速使用
csharp
var db = new SmartNpgsqlService("Server=localhost;Database=test;User ID=;Password=");
// 插入数据
await db.ExecuteNonQueryAsync(@"INSERT INTO ""users"" (""Name"") VALUES (@name)",[new NpgsqlParameter("@name", "Alice")]);
// 批量事务操作
var sqls =
[
@"UPDATE ""accounts"" SET ""balance"" = ""balance"" - 100 WHERE ""id"" = 1",
@"UPDATE ""accounts"" SET ""balance"" = ""balance"" + 100 WHERE ""id"" = 2"
];
await db.ExecuteNonQuerysAsync(sqls);
// 查询数据
var dt = await db.GetDataTableAsync(@"SELECT * FROM ""users"" WHERE ""Age"" > @age", [new MySqlParameter("@age", 18)]);
依赖注入
csharp
// Startup.cs
services.AddSmartNpgsql("your_connection_string");
注意事项
- 当sql语句中的列名或者表名包含大写字母或者特殊符号时,需要使用引号括起来
- 事务方法返回的行数为近似值,不可用于精确计算
- 不完全支持存储过程调用
- 推荐配合NpgsqlParameter使用防止SQL注入
Developed by zenglei
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Npgsql (>= 9.0.2)
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Npgsql (>= 9.0.2)
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Npgsql (>= 9.0.2)
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 |
---|---|---|
4.0.0 | 46 | 3 days ago |
3.0.3 | 125 | 23 days ago |
3.0.2 | 98 | a month ago |
3.0.1 | 100 | 2 months ago |
3.0.0 | 97 | 2 months ago |
2.0.5 | 101 | 2 months ago |
2.0.4 | 97 | 2 months ago |
2.0.3 | 105 | 2 months ago |
2.0.2 | 119 | 4 months ago |
2.0.1 | 104 | 4 months ago |
2.0.0 | 99 | 4 months ago |
1.0.0.2 | 108 | 5 months ago |
1.0.0.1 | 113 | 6 months ago |
1.0.0 | 100 | 6 months ago |