为 .Net Core 选择正确版本的 GCP 数据存储库

Choosing the right version of GCP''s Datastore library for .Net Core

对于 GCP 的数据存储,我看到了两个版本的 Nuget,不确定它们之间有什么区别,以及在使用 .Net Core 应用程序时应该使用哪个

Google.Cloud.Datastore.V1
Google.Apis.Datastore.v1beta3

虽然 https://cloud.google.com/datastore/docs/reference/libraries#client-libraries-install-csharp 的示例应用程序使用第一个,但第二个似乎是最近更新的。

Disclaimer/authority:我是 Google.Cloud.Datastore.V1 的主要作者,我负责 Google .NET 的云客户端库。所以我知道我在这里说的是什么,但我确实有偏见:)

您真的应该在 Google.Cloud.Datastore.V1Google.Apis.Datastore.v1 之间进行选择 - 此时使用 beta 库没有意义。

但是,Google.Cloud.Datastore.V1 是首选库。差异是:

  • Google.Apis.Datastore.v1 对 HTTP/1.1 有效载荷 JSON。 Google.Cloud.Datastore.V1 使用 gRPC 和协议缓冲区负载。
  • Google.Apis.Datastore.v1 完全是自动生成的,使用我们的 "old" 代码生成技术。它应该可以工作,但不如最近的代码生成那么干净。 Google.Cloud.Datastore.V1 是生成代码和手写代码的混合。

关于手写代码的部分很重要 - 这就是我们 类 和 DatastoreTransaction 的方式,它比手动跟踪交易 ID 等更令人愉快。有还有很多关于 protobuf 消息的转换和额外的方法,使数据存储更容易使用。

这两个库应该可以与 .NET Core 一起正常工作,但是 Google.Cloud.Datastore.V1 确实需要 gRPC 本机库,该库目前仅适用于 x86 和 x64。目前 UWP、Xamarin 或 Unity 都不支持这两个库,但可能有 某些 上下文,其中 Google.Apis.Datastore.v1 适合您,但 gRPC 库不支持。不过,我会先尝试使用 Google.Cloud.Datastore.V1