Smart.Data.SqlServer
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.SqlServer --version 3.0.2
NuGet\Install-Package Smart.Data.SqlServer -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.SqlServer" 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.SqlServer" Version="3.0.2" />
<PackageReference Include="Smart.Data.SqlServer" />
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.SqlServer --version 3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Smart.Data.SqlServer, 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.
#:package Smart.Data.SqlServer@3.0.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=Smart.Data.SqlServer&version=3.0.2
#tool nuget:?package=Smart.Data.SqlServer&version=3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Smart.Data.SqlServer
基于 Microsoft.Data.SqlClient 封装的轻量级 SQL Server 数据库操作库,支持 .NET 6/8/9。
功能特性
- 原生 T-SQL 语法支持
- 高性能批处理操作
- 事务与连接池管理
- 参数化查询防护
- 存储过程调用支持
安装
bash
dotnet add package Smart.Data.SqlServer
快速使用
csharp
var db = new SmartSqlServerService("Server=.;Database=Northwind;Integrated Security=true;");
// 插入数据
await db.ExecuteNonQueryAsync("INSERT INTO Employees (FirstName) VALUES (@name)",[new SqlParameter("@name", "Alice")]);
// 批量事务操作
var sqls = new List<string>
{
"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("sp_GetEmployeeByDepartment",[new SqlParameter("@DeptId", 10)],CommandType.StoredProcedure);
依赖注入
csharp
// Startup.cs
services.AddSmartSqlServer("your_connection_string");
注意事项
- 连接字符串需启用 MultipleActiveResultSets (MARS) 时显式声明
- 保留字列名使用方括号包裹:
[Order] - 日期类型建议明确指定
DateTime2精度 - 事务隔离级别默认为 ReadCommitted
- 批量操作建议配合
SqlBulkCopy使用 - 始终使用参数化查询防止 SQL 注入
Developed by zenglei
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Data.SqlClient (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
-
net9.0
- Microsoft.Data.SqlClient (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection (>= 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.2 | 85 | 1/8/2026 |
| 4.0.1 | 85 | 12/30/2025 |
| 4.0.0 | 184 | 4/5/2025 |
| 3.0.3 | 212 | 3/16/2025 |
| 3.0.2 | 183 | 2/26/2025 |
| 3.0.1 | 183 | 2/15/2025 |
| 3.0.0 | 181 | 2/15/2025 |
| 2.0.4 | 176 | 2/15/2025 |
| 2.0.3 | 165 | 2/13/2025 |
| 2.0.2 | 198 | 2/9/2025 |
| 2.0.1 | 186 | 12/7/2024 |
| 2.0.0 | 178 | 11/26/2024 |
| 1.0.0.1 | 164 | 10/9/2024 |
| 1.0.0 | 180 | 9/25/2024 |