SZORM 1.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 SZORM --version 1.0.2
NuGet\Install-Package SZORM -Version 1.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="SZORM" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SZORM" Version="1.0.2" />
<PackageReference Include="SZORM" />
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 SZORM --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SZORM, 1.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 SZORM@1.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=SZORM&version=1.0.2
#tool nuget:?package=SZORM&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SZORMCore - 轻量级 .NET ORM 框架核心引擎
SZORMCore 是一个轻量级、高性能的 .NET ORM(对象关系映射)框架核心引擎,提供简洁的 API 和强大的功能特性。
✨ 功能特性
核心功能
- ✅ 简洁的 API 设计 - 类似 Entity Framework 的流畅 API
- ✅ 强大的实体映射 - 基于 Attribute 的约定配置
- ✅ 自动化 SQL 生成 - 无需手写 SQL,自动生成增删改查语句
- ✅ 事务支持 - 完整的 ACID 事务管理
- ✅ 连接池管理 - 高效的数据库连接复用机制
高级功能
- 🔐 字段级加密存储 - 支持 SM4/AES 加密算法
- 🔍 哈希索引支持 - 支持加密字段的模糊查询
- 📊 复杂查询支持 - 支持 Lambda 表达式查询
- 🎯 主键自动生成 - 内置 SnowID 分布式 ID 生成器
- 📝 SQL 日志 - 完整的 SQL 执行日志记录
📁 项目依赖
SZORM.Core (本包)
↓ 引用
SZORM.Attribute (属性定义库)
↓ 零依赖
🚀 快速开始
1. 安装
dotnet add package SZORM
或直接在 .csproj 中添加:
<ItemGroup>
<PackageReference Include="SZORM" Version="1.0.0" />
</ItemGroup>
2. 定义实体类
using SZORM.Attribute;
using System;
[SZTable("Users")] // 映射到 Users 表
public class User
{
[SZColumn(IsPrimaryKey = true)] // 主键
public long Id { get; set; }
[SZColumn(IsNotNull = true, MaxLength = 50)] // 非空,最大长度 50
public string Name { get; set; }
[SZColumn(IsEncrypt = true, EncryptMode = EncryptMode.SM4)] // 加密存储
public string IdCard { get; set; }
}
3. 创建 DbContext
using SZORM.Core;
public class MyDbContext : DbContext
{
public MyDbContext()
: base("Server=localhost;Database=TestDB;Integrated Security=true;")
{
}
public DbSet<User> Users { get; set; }
public DbSet<Order> Orders { get; set; }
}
4. 基本 CRUD 操作
using (var db = new MyDbContext())
{
// 添加数据
var user = new User
{
Name = "张三",
IdCard = "110101199001011234" // 自动加密存储
};
db.Users.Add(user);
db.Commit();
// 查询数据
var users = db.Users.Where(u => u.Name.Contains("张")).ToList();
// 更新数据
user.Name = "李四";
db.Users.Update(user);
db.Commit();
// 删除数据
db.Users.Remove(user);
db.Commit();
}
📚 详细功能文档
由于 README 长度限制,详细功能文档请访问:
功能速查表
| 功能 | 文档链接 |
|---|---|
| 实体映射 | Entity Mapping |
| 查询功能 | Query |
| 插入功能 | Insert |
| 更新功能 | Update |
| 删除功能 | Delete |
| 事务管理 | Transaction |
| 加密存储 | Encryption |
| SQL 日志 | SQL Logging |
⚙️ 配置说明
szorm.json 配置
{
"connectionString": "Server=localhost;Database=TestDB;Integrated Security=true;",
"databaseType": "SqlServer",
"maxPoolSize": 100,
"minPoolSize": 0,
"sm4Key": "0123456789abcdeffedcba9876543210",
"sm4IV": "0123456789abcdef",
"sm4Mode": "CBC",
"aesKey": "0123456789abcdef0123456789abcdef",
"aesIV": "0123456789abcdef",
"hashMode": "SM3"
}
详细配置说明请参考:Configuration
🚀 性能优化
1. 连接池配置
{
"maxPoolSize": 200,
"minPoolSize": 10,
"connectionLifetime": 300
}
2. 批量操作
// 使用 AddRange 批量插入
var users = new List<User>();
for (int i = 0; i < 1000; i++)
{
users.Add(new User { Name = $"User{i}", Age = i % 100 });
}
db.Users.AddRange(users);
db.Commit();
详细性能优化建议请参考:Performance Tuning
📝 最佳实践
1. 使用 using 语句管理资源
// ✅ 推荐
using (var db = new MyDbContext())
{
var users = db.Users.ToList();
}
2. 及时提交事务
using (var db = new MyDbContext())
{
db.Users.Add(new User { Name = "张三" });
db.Commit(); // 及时提交
}
详细最佳实践请参考:Best Practices
❓ 常见问题
1. 如何映射视图?
[SZTable("UserView")]
public class UserView
{
[SZColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string UserName { get; set; }
public string OrderNo { get; set; }
}
更多常见问题请参考:FAQ
📄 许可证
本项目采用 MIT 许可证。详见 LICENSE 文件。
🤝 贡献
欢迎提交 Issue 和 Pull Request!
📧 联系方式
如有问题或建议,请提交 Issue 或联系项目维护者。
⚡ 相关链接
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.
-
net10.0
- BouncyCastle.Cryptography (>= 2.7.0)
- Microsoft.Data.SqlClient (>= 7.0.1)
- Microsoft.Data.Sqlite (>= 10.0.9)
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.Configuration.Json (>= 10.0.9)
- MySqlConnector (>= 2.6.0)
- Npgsql (>= 10.0.3)
- Oracle.ManagedDataAccess.Core (>= 23.26.200)
- SZORM.Attribute (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.