CSoft.DataPairs.Ceras 11.0.0

dotnet add package CSoft.DataPairs.Ceras --version 11.0.0
                    
NuGet\Install-Package CSoft.DataPairs.Ceras -Version 11.0.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="CSoft.DataPairs.Ceras" Version="11.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSoft.DataPairs.Ceras" Version="11.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CSoft.DataPairs.Ceras" />
                    
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 CSoft.DataPairs.Ceras --version 11.0.0
                    
#r "nuget: CSoft.DataPairs.Ceras, 11.0.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 CSoft.DataPairs.Ceras@11.0.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=CSoft.DataPairs.Ceras&version=11.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CSoft.DataPairs.Ceras&version=11.0.0
                    
Install as a Cake Tool

DataPairs

CSoft.DataPairs.Ceras 使用 Ceras 将键值数据保存为 SQLite BLOB 或二进制文件。

安装

dotnet add package CSoft.DataPairs.Ceras

11.0.0 提供 netstandard2.0、net8.0、net9.0、net10.0 和 net11.0 资产。

读写数据

DataPair<T> 用一个键绑定一个模型。T 需要是具有公共无参构造函数的类。

using System;
using System.Collections.Generic;
using System.IO;
using DataPairs;
using DataPairs.Interfaces;

var directory = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MyApp");
Directory.CreateDirectory(directory);

IDataPair<Data> pair = new DataPair<Data>(
    "Data", Path.Combine(directory, "data.db"), StorageType.SQLite);

var data = await pair.TryGetValueAsync();
data.A = 1.25m;
data.B.Add(2m);
await pair.TryInitOrUpdateAsync(data);

public class Data
{
    public decimal A { get; set; }
    public List<decimal> B { get; set; } = new List<decimal>();
}

键不存在时,TryGetValueAsync() 返回 new T()。修改读取结果后,调用 TryInitOrUpdateAsync() 才会保存。需要删除时调用 await pair.TryRemoveAsync()。

可以复用 DataPair<T> 实例,并在应用初始化时调用一次 TryGetValueAsync() 预热缓存。缓存按实例维护,其他实例或进程写入的数据可通过新实例读取。缓存克隆可用 [FastDeepClonerIgnore] 排除字段或属性。

存储方式

选项 path 的含义 省略路径时
StorageType.SQLite SQLite 数据库文件路径 当前工作目录下的 PairsDB.dll
StorageType.File 数据目录,键 Data 写到其下的 Config/Data.json 应用基目录下的 Config
StorageType.Xamarin SQLite 数据库文件路径 Environment.SpecialFolder.Personal 下的 PairsDB.dll

文件模式可使用 new DataPair<Data>("Data", directory, StorageType.File)。.json 是历史扩展名,文件内容是 Ceras 二进制数据。应从应用控制的可信存储读取这些数据。

StorageType.Xamarin 保留个人目录的路径选择。SQLitePCLRaw 3.x 已移除经典 Xamarin 原生库支持。 SQLitePCLRaw 3.0 说明

如果 .NET Framework 应用加载 SQLite 时遇到 BadImageFormatException,请将 PlatformTarget 设为运行进程对应的 x64 或 x86,以选择同位数的 SQLite 原生库。

11.0.0 升级说明

  • 新增 .NET 11 和 EF Core SQLite 11 支持。netstandard2.0 使用 EF Core SQLite.Core 3.1.32 和 SQLitePCLRaw 3.0.3。
  • 为修复 .NET Framework 恢复依赖时出现的安全警告,netstandard2.0 将 Newtonsoft.Json 的最低版本设为 13.0.4。
  • SQLite 同键写入使用 UPSERT,文件更新使用同目录临时文件替换。内容相同的二进制数据会跳过写入。
  • 新实例可直接删除已保存的键。缓存克隆按对象引用处理循环和共享引用。
  • .NET 8 及以上在 Unix 上新建的文件仅允许所有者读写,更新已有文件时保留其权限位。
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  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.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
11.0.0 114 11/12/2026
10.0.2 178 6/25/2026
10.0.1 154 6/24/2026
10.0.0 424 11/12/2025
9.1.0 304 10/24/2025
9.0.1 285 1/23/2025
9.0.0 244 11/22/2024
8.0.4 273 7/18/2024
8.0.3 263 5/10/2024
8.0.2 265 4/11/2024
8.0.1 260 3/22/2024
8.0.0 357 11/15/2023
7.0.2 421 4/20/2023
7.0.1 597 2/2/2023 7.0.1 is deprecated because it is no longer maintained.
7.0.0 707 11/9/2022 7.0.0 is deprecated because it is no longer maintained.
6.0.6 752 8/12/2022 6.0.6 is deprecated because it is no longer maintained.
6.0.5 791 5/11/2022 6.0.5 is deprecated because it is no longer maintained.
6.0.4 752 5/10/2022 6.0.4 is deprecated because it is no longer maintained.
6.0.3 770 3/15/2022 6.0.3 is deprecated because it is no longer maintained.
6.0.2 791 2/23/2022 6.0.2 is deprecated because it is no longer maintained.
Loading failed

支持 .NET 11,更新 SQLite 依赖并修复二进制持久化问题