Smart.Data.MySql 3.0.1

dotnet add package Smart.Data.MySql --version 3.0.1                
NuGet\Install-Package Smart.Data.MySql -Version 3.0.1                
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.MySql" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Smart.Data.MySql --version 3.0.1                
#r "nuget: Smart.Data.MySql, 3.0.1"                
#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.
// Install Smart.Data.MySql as a Cake Addin
#addin nuget:?package=Smart.Data.MySql&version=3.0.1

// Install Smart.Data.MySql as a Cake Tool
#tool nuget:?package=Smart.Data.MySql&version=3.0.1                

Smart.Data.MySql

NuGet
基于 MySqlConnector 封装的轻量级 MySQL 数据库操作库,支持 .NET 6/8/9。

功能特性

  • 异步数据库操作(增删改查)
  • 自动连接管理
  • 事务批处理支持
  • DI 友好设计
  • 参数化查询防护

安装

bash
dotnet add package Smart.Data.MySql

快速使用

csharp
var db = new SmartMySqlService("Server=localhost;Database=test;Uid=root;");

// 插入数据
await db.ExecuteNonQueryAsync("INSERT INTO users (Name) VALUES (@name)",[new MySqlParameter("@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.AddSmartMySql("your_connection_string");

注意事项

  • 列名若为MySQL保留字需用反引号包裹:Desc
  • 事务方法返回的行数为近似值,不可用于精确计算
  • 不完全支持存储过程调用
  • 推荐配合MySqlParameter使用防止SQL注入

Developed by zenglei

Product 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.

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
3.0.1 70 2/15/2025
3.0.0 62 2/15/2025
2.0.4 70 2/15/2025
2.0.3 65 2/13/2025
2.0.2 70 2/9/2025
2.0.1 101 12/7/2024
2.0.0 91 11/26/2024
1.0.0.2 106 10/9/2024
1.0.0.1 106 9/25/2024
1.0.0 103 9/25/2024