Smart.Data.Sqlite
2.0.4
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.Sqlite --version 2.0.4
NuGet\Install-Package Smart.Data.Sqlite -Version 2.0.4
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.Sqlite" Version="2.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Smart.Data.Sqlite --version 2.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Smart.Data.Sqlite, 2.0.4"
#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.Sqlite as a Cake Addin #addin nuget:?package=Smart.Data.Sqlite&version=2.0.4 // Install Smart.Data.Sqlite as a Cake Tool #tool nuget:?package=Smart.Data.Sqlite&version=2.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Smart.Data.Sqlite
基于 Microsoft.Data.Sqlite 封装的轻量级 SQLite 数据库操作库,支持 .NET 6/8/9。
功能特性
- 零配置嵌入式数据库支持
- 跨平台文件数据库操作
- 事务批处理与并发控制
- 内存数据库快速访问
- 参数化查询防护
安装
bash
dotnet add package Smart.Data.Sqlite
快速使用
csharp
// 文件数据库
var db = new SmartSqliteService("Data Source=mydb.sqlite");
// 内存数据库
// var db = new SmartSqliteService("Data Source=:memory:");
// 插入数据
await db.ExecuteNonQueryAsync("INSERT INTO users (Name) VALUES (@Name)", [new SqliteParameter("@Name", "张三")])]);
// 批量事务操作
var sqls = new List<string>
{
"CREATE TABLE IF NOT EXISTS logs (Id INTEGER PRIMARY KEY, Content TEXT)",
"INSERT INTO logs (Content) VALUES ('system start')"
};
await db.ExecuteNonQuerysAsync(sqls);
依赖注入
csharp
// Startup.cs
services.AddSmartSqlite("Data Source=app.db");
注意事项
- 文件路径需使用绝对路径(Linux/macOS 注意权限)
- 内存数据库连接需保持单例生命周期
- 并发写入需配置
BusyTimeout
参数 - 保留字列名使用方括号包裹:
[Group]
- 不支持存储过程(SQLite 无存储过程概念)
- 建议启用
Foreign Keys
参数:PRAGMA foreign_keys = 1
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.Data.Sqlite (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
-
net8.0
- Microsoft.Data.Sqlite (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
-
net9.0
- Microsoft.Data.Sqlite (>= 9.0.2)
- 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.