Zeek.Data.DapperAot 10.0.38

Zeek.Data.DapperAot

Zeek.Data.DapperAotZeek.Data 的 Dapper.AOT build helper,用来减少应用项目启用 Dapper.AOT 时的项目文件样板代码。

它不是数据库 provider,不是 ORM,也不提供 Zeek runtime API。

适用场景

  • 应用使用 Zeek.Data / Zeek.Data.Sqlite 等 provider 打开 DbConnection
  • 业务代码希望继续直接调用 Dapper API。
  • 应用需要 NativeAOT 友好的 Dapper.AOT 编译期拦截器接线。
  • 不希望每个应用项目重复配置 InterceptorsPreviewNamespaces[module: DapperAot]

安装 / 引用

发布包消费时引用:

<PackageReference Include="Zeek.Data.DapperAot" />

当前 sample 使用发布态 PackageReference 消费 Zeek.Data.DapperAot,包版本由根目录 Directory.Packages.props 统一管理。

快速开始

引用 helper 后,业务代码仍直接使用 Dapper:

await using var connection = await database.OpenConnectionAsync(cancellationToken);
var rows = await connection.QueryAsync<TodoItem>(
    "SELECT Id, Title, IsCompleted FROM Todos;");

helper 只负责构建接线:

  1. 引入 Dapper
  2. 引入 Dapper.AOT
  3. 设置 InterceptorsPreviewNamespaces
  4. 自动生成 [module: DapperAot]

Nupkg 只包含 buildTransitive props/targets、README 和 NuGet metadata,不输出 runtime DLL;未引用 helper 的项目不会获得这些构建资产。

AOT / Trim

  • AOT 支持等级:Required。
  • Trim 策略:构建期 helper,不依赖运行时扫描。
  • 反射策略:不提供运行时反射或动态代码生成。

Dapper.AOT 仍要求应用按它可识别的调用形态编写查询;当前 1.0.52 已验证主路径使用 string/parameters/transaction overload。CommandDefinition 在当前 Native AOT sample 中会落回传统 Dapper,因此需要严格取消的命令应直接使用 ADO.NET。本 helper 不会隐藏 warning,也不会把任意 Dapper 用法变成 AOT safe。

Sample

  • ../../samples/Zeek.Data.DapperAotSample/

完整文档

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

当前限制

  • 不封装 QueryAsyncExecuteAsyncCommandDefinition
  • 不提供 Repository、UnitOfWork、SQL DSL 或迁移平台。
  • 如果应用需要完全显式控制,可以不引用本 helper,改为手动引用 Dapper / Dapper.AOT 并手写 [module: DapperAot]

No packages depend on Zeek.Data.DapperAot.

.NET 10.0

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