SonnetDB 3.0.0

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

SonnetDB

SonnetDB NuGet 包提供 SonnetDB 的 ADO.NET 访问层。源码项目、程序集和命名空间仍为 SonnetDB.Data,统一支持本地嵌入式和远程 SonnetDB 连接。

本地嵌入式连接的 Data Source=./demo-data 指向数据库目录,不是单个数据库文件。目录布局与 SonnetDB.Core 一致,适合随应用进程内打开;远程连接则通过 HTTP 访问 SonnetDB Server。

本包未声明 IsAotCompatible=true。ADO.NET 基类和 DbDataReader.GetSchemaTable() 等路径在 BCL 内部存在反射边界;需要 Native AOT 的嵌入式场景建议直接使用 SonnetDB.Core 的 Tsdb API。远程客户端内部使用 source-generated JSON 上下文,但包级别仍按 ADO.NET 兼容边界声明为非 AOT 包。

安装

dotnet add package SonnetDB

本地嵌入式连接

using SonnetDB.Data;

using var connection = new SndbConnection("Data Source=./demo-data");
connection.Open();

using var command = connection.CreateCommand();
command.CommandText = "SELECT count(*) FROM cpu";

var count = (long)(command.ExecuteScalar() ?? 0L);
Console.WriteLine(count);

远程服务器连接

using SonnetDB.Data;

using var connection = new SndbConnection(
    "Data Source=sonnetdb+http://127.0.0.1:5080/metrics;Token=sonnetdb-admin-token");
connection.Open();

using var command = connection.CreateCommand();
command.CommandText = "SHOW DATABASES";

using var reader = command.ExecuteReader();
while (reader.Read())
{
    Console.WriteLine(reader.GetString(0));
}

Microsoft.Extensions.VectorData

SonnetDB.Data.VectorData 提供 Microsoft.Extensions.VectorData adapter。默认情况下,一个 VectorData collection 会映射为 SonnetDB DOCUMENT COLLECTION:record key 存为文档 id,数据字段和向量字段存入 JSON document,向量搜索通过 vector_search(...) 读取 JSON number array。

using Microsoft.Extensions.VectorData;
using SonnetDB.Data;
using SonnetDB.Data.VectorData;

await using var connection = new SndbConnection("Data Source=./demo-data");
using var store = new SonnetDBVectorStore(connection);

var collection = store.GetCollection<string, KnowledgeRecord>("knowledge");
await collection.EnsureCollectionExistsAsync();

await collection.UpsertAsync(new KnowledgeRecord
{
    Id = "kb-1",
    Title = "Pump alarm guide",
    Site = "north",
    Embedding = [1, 0, 0],
});

var results = await collection
    .SearchAsync(
        new ReadOnlyMemory<float>([1, 0, 0]),
        top: 5,
        new VectorSearchOptions<KnowledgeRecord>
        {
            IncludeVectors = true,
            Filter = record => record.Site == "north",
        })
    .ToArrayAsync();

public sealed class KnowledgeRecord
{
    [VectorStoreKey]
    public string Id { get; set; } = string.Empty;

    [VectorStoreData]
    public string Title { get; set; } = string.Empty;

    [VectorStoreData]
    public string Site { get; set; } = string.Empty;

    [VectorStoreVector(3, DistanceFunction = DistanceFunction.CosineDistance)]
    public float[] Embedding { get; set; } = [];
}

measurement 仍用于时序数据和时序 VECTOR(N) 列;通用 VectorData collection 不默认映射到 measurement,避免把非时序记录强行绑定到时间轴。

发布包和默认示例配置见仓库根目录 docs/releases/。

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

NuGet packages (10)

Showing the top 5 NuGet packages that depend on SonnetDB:

Package Downloads
mooSQL.Ext.Core

一个纯粹、高可用、自由的面向数据库的连接库

mooSQL.Ext

一个纯粹、高可用、自由的面向数据库的连接库

SonnetDB.EntityFrameworkCore

SonnetDB 的 Entity Framework Core 关系型 Provider,提供 UseSonnetDB、SQL 生成、类型映射、迁移 SQL 和基础查询翻译。

SonnetDB.Caching

SonnetDB KV-backed EasyCaching and IDistributedCache providers.

SonnetDB.Caching.EasyCaching

SonnetDB KV-backed EasyCaching provider.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on SonnetDB:

Repository Stars
IoTSharp/IoTSharp
IoTSharp is an open-source IoT platform for data collection, processing, visualization, and device management.
Version Downloads Last Updated
5.2.0 201 11/23/2026
5.1.1 158 11/15/2026
5.0.0 580 11/4/2026
4.5.0-preview.ef266.5 313 10/13/2026
4.0.0 547 9/27/2026
3.1.0 585 8/24/2026
3.0.1 273 7/8/2026
3.0.0 176 7/7/2026
2.5.0 328 6/26/2026
2.2.0 168 6/16/2026
2.1.1 225 6/15/2026
2.1.0 153 6/14/2026
2.0.0 165 6/14/2026
1.2.0 220 5/8/2026
1.1.0 154 5/6/2026
1.0.0 425 4/26/2026
0.2.1 149 5/3/2026
0.2.0 146 5/3/2026
0.1.0 141 5/3/2026