Zeek.Data 10.0.41

Zeek.Data

Zeek.Data 是面向桌面应用的轻量 ADO.NET Data Core。

它只统一 IDatabase.OpenConnectionAsync(...)、marker 数据库和显式 initializer;连接与 transaction 直接使用 ADO.NET。它不是 ORM、SQL DSL、Repository、UnitOfWork 或迁移平台。

适用场景

  • 桌面应用需要一个默认数据库入口。
  • 应用需要用 marker type 区分多个数据库。
  • 业务代码希望直接使用 ADO.NET、Dapper 或 Dapper.AOT。
  • 启动时需要显式执行 schema 或种子数据初始化。

安装 / 引用

发布包消费时引用基础包和具体 provider;当前正式 Data sample 已通过 PackageReference 消费已发布包,版本由根目录 Directory.Packages.props 统一管理。

<PackageReference Include="Zeek.Data" />

快速开始

普通应用通常不直接只引用 Zeek.Data,而是依赖某个 provider,例如 Zeek.Data.Sqlite

public static IReadOnlyList<ModuleDependency> Dependencies =>
    [ModuleDependency.Of<SqliteModule>()];

业务代码注入默认数据库:

public sealed class TodoStore(IDatabase database)
{
    public async Task<int> CountAsync(CancellationToken cancellationToken)
    {
        await using var connection =
            await database.OpenConnectionAsync(cancellationToken);
        await using var command = connection.CreateCommand();
        command.CommandText = "SELECT COUNT(*) FROM Todos;";
        return Convert.ToInt32(await command.ExecuteScalarAsync(cancellationToken));
    }
}

多个数据库时使用 marker type 注入 IDatabase<TDatabase>,不要使用字符串注册表。

AOT / Trim

  • AOT 支持等级:Required。
  • Trim 策略:显式 provider、显式 marker type、显式 initializer,不依赖运行时扫描。
  • 反射策略:仅 DI 构造;查询映射交给 ADO.NET、Dapper 或 Dapper.AOT。

Sample

  • ../../samples/Zeek.Data.SqliteSample/
  • ../../samples/Zeek.Data.DapperAotSample/
  • ../../samples/Zeek.Data.RemoteDatabasesSample/

完整文档

  • ../../docs/modules/Zeek.Data.md

当前限制

  • Zeek.Data 只定义连接入口和 initializer contract;transaction 语义由 ADO.NET driver 负责。
  • 不提供 ORM、迁移平台、业务 Repository 或 SQL DSL。
  • 真实远程数据库连接需要外部 MySQL / PostgreSQL / SQL Server 服务配合验证。

Showing the top 20 packages that depend on Zeek.Data.

Packages Downloads
Zeek.Data.MySql
Lightweight MySQL provider module for Zeek.Data.
8
Zeek.Data.PostgreSql
Lightweight PostgreSQL provider module for Zeek.Data.
8
Zeek.Data.Sqlite
Lightweight SQLite provider module for Zeek.Data.
8
Zeek.Data.SqlServer
Lightweight SQL Server provider module for Zeek.Data.
8
Zeek.Data.MySql
Lightweight MySQL provider module for Zeek.Data.
5
Zeek.Data.PostgreSql
Lightweight PostgreSQL provider module for Zeek.Data.
5
Zeek.Data.Sqlite
Lightweight SQLite provider module for Zeek.Data.
5
Zeek.Data.SqlServer
Lightweight SQL Server provider module for Zeek.Data.
5
Zeek.Data.MySql
Lightweight MySQL provider module for Zeek.Data.
4
Zeek.Data.PostgreSql
Lightweight PostgreSQL provider module for Zeek.Data.
4
Zeek.Data.Sqlite
Lightweight SQLite provider module for Zeek.Data.
4
Zeek.Data.SqlServer
Lightweight SQL Server provider module for Zeek.Data.
4
Zeek.Data.Sqlite
Lightweight SQLite provider module for Zeek.Data.
3
Zeek.Data.MySql
Lightweight MySQL provider module for Zeek.Data.
3
Zeek.Data.PostgreSql
Lightweight PostgreSQL provider module for Zeek.Data.
3

.NET 10.0

  • No dependencies.

Version Downloads Last updated
10.0.42 3 07/29/2026
10.0.41 8 07/22/2026
10.0.40 3 07/22/2026
10.0.39 2 07/19/2026
10.0.38 4 07/17/2026
10.0.37 1 07/16/2026
10.0.36 5 06/29/2026
10.0.35 1 06/29/2026
10.0.31 5 06/27/2026
10.0.30 2 06/27/2026
10.0.29 2 06/26/2026
10.0.28 2 06/26/2026
10.0.27 2 06/26/2026
10.0.26 4 06/25/2026
10.0.25 3 06/24/2026