SuncodeSoftware.SuperSDK.Data 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SuncodeSoftware.SuperSDK.Data --version 2.2.0
                    
NuGet\Install-Package SuncodeSoftware.SuperSDK.Data -Version 2.2.0
                    
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="SuncodeSoftware.SuperSDK.Data" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SuncodeSoftware.SuperSDK.Data" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SuncodeSoftware.SuperSDK.Data" />
                    
Project file
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 SuncodeSoftware.SuperSDK.Data --version 2.2.0
                    
#r "nuget: SuncodeSoftware.SuperSDK.Data, 2.2.0"
                    
#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 SuncodeSoftware.SuperSDK.Data@2.2.0
                    
#: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=SuncodeSoftware.SuperSDK.Data&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SuncodeSoftware.SuperSDK.Data&version=2.2.0
                    
Install as a Cake Tool

SuperSDK.Data

数据访问层,提供统一的数据持久化接口。

🎯 核心功能

  • Entity Framework Core 集成
  • SQLite 数据库支持
  • SQLCipher 加密字段支持
  • CRUD 统一操作接口
  • 事务管理
  • 加密字段自动处理

📦 依赖

  • SuperSDK.Core (MessageBus 日志集成)
  • Microsoft.EntityFrameworkCore.Sqlite
  • Microsoft.Data.Sqlite.Core

🚀 快速开始

1. 定义实体模型

using SuperSDK.Data;
using System.ComponentModel.DataAnnotations;

public class TestConfig : IEntity, IDatabaseEntity, ITableEntity
{
    [Key]
    public string Id { get; set; } = Guid.NewGuid().ToString();
    
    [Required]
    public string ConfigName { get; set; } = "";
    
    public string ConfigValue { get; set; } = "";
    
    // 指定数据库名(与项目名一致)
    public string DatabaseName => "YourProjectName";
    
    // 指定表名(与类名一致)
    public string TableName => "TestConfig";
}

2. 初始化数据库

using SuperSDK.Data;

// 注册实体
DbContextFactory.RegisterEntity<TestConfig>();

// 初始化数据库
DbContextFactory.Initialize();

3. CRUD 操作

using SuperSDK.Data;

// 插入
var config = new TestConfig 
{ 
    ConfigName = "AppTheme", 
    ConfigValue = "Dark" 
};
EntityStore.Insert(config);

// 查询所有
var allConfigs = EntityStore.GetAll<TestConfig>();

// 条件查询
var darkConfigs = EntityStore.Find<TestConfig>(c => c.ConfigValue == "Dark");

// 更新
config.ConfigValue = "Light";
EntityStore.Update(config);

// 删除
EntityStore.Delete(config);

🔐 加密字段

对于需要加密存储的敏感数据:

public class UserProfile : IEntity, IEncryptedEntity, IDatabaseEntity, ITableEntity
{
    [Key]
    public string Id { get; set; } = Guid.NewGuid().ToString();
    
    public string Username { get; set; } = "";
    
    // 加密字段 - 自动存储在 secure.db 中
    [Encrypted]
    public string Password { get; set; } = "";
    
    [Encrypted]
    public List<string> ApiKeys { get; set; } = new();
    
    public string DatabaseName => "YourProjectName";
    public string TableName => "UserProfile";
}

// 初始化加密数据库
EncryptedFieldManager.Initialize(
    "Data/secure.db", 
    "YourSecurePassword123!"
);

加密字段自动处理:

  • 插入/更新时自动加密并保存到 secure.db
  • 查询时自动解密并填充到实体属性
  • 删除时自动清理加密数据

🔧 高级功能

事务操作

using (var tx = EntityStore.BeginTransaction<TestConfig>())
{
    tx.Add(config1);
    tx.Add(config2);
    tx.Update(config3);
    tx.Commit(); // 或 tx.Rollback()
}

分页查询

var result = EntityStore.GetPaged<TestConfig>(
    pageIndex: 0,
    pageSize: 20,
    orderBy: c => c.ConfigName,
    isDescending: false
);

Console.WriteLine($"Total: {result.TotalCount}, Pages: {result.TotalPages}");
foreach (var item in result.Data)
{
    Console.WriteLine(item.ConfigName);
}

📂 数据库文件位置

[ApplicationDirectory]/Data/
├── YourProjectName.db    # 主数据库(明文字段)
└── secure.db             # 加密数据库(加密字段,AES-256)

📝 License

MIT License - See LICENSE file for details

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SuncodeSoftware.SuperSDK.Data:

Package Downloads
SuncodeSoftware.SuperSDK.UI

Avalonia UI 通用组件库 - 通知管理、对话框、ViewModelBase 等

SuncodeSoftware.SuperSDK.App

Application foundation framework for Avalonia-based Goes applications

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 0 1/16/2026
2.2.0 0 1/16/2026
2.1.0 0 1/16/2026
2.0.8 40 1/15/2026
2.0.7 27 1/15/2026
2.0.6 32 1/15/2026
2.0.5 31 1/15/2026
2.0.4 38 1/15/2026
2.0.3 36 1/15/2026
2.0.2 34 1/15/2026
2.0.1 40 1/15/2026
2.0.0 36 1/15/2026
1.2.6 215 12/23/2025
1.2.5 204 12/23/2025
1.2.4 206 12/23/2025
1.2.2 205 12/23/2025
1.2.1 204 12/22/2025
1.2.0 209 12/22/2025
1.1.8 204 12/22/2025
1.1.7 200 12/22/2025
1.1.6 201 12/22/2025
1.1.5 206 12/22/2025
1.1.4 211 12/22/2025
1.1.3 204 12/22/2025
1.1.2 208 12/22/2025
1.1.1 207 12/22/2025
1.0.7 287 12/16/2025
1.0.6 284 12/16/2025
1.0.5 290 12/16/2025
1.0.4 295 12/16/2025
1.0.3 293 12/16/2025
1.0.2 292 12/16/2025
1.0.1 236 12/15/2025
1.0.0 223 12/15/2025

all bring readme