c# - Microsoft.Azure.Cosmos.Tables 到 Azure.Data.Tables 迁移 : TableEntity Inheritance

标签 c# azure azure-storage

我正在尝试将一些旧代码从 Microsoft.AzureCosmos.Tables 迁移到 Azure.Storage.Tables。 TableEntity 类被密封在 Azure.storage.Tables 中,那么如何解决这个问题?

    public class HistoricalValues : TableEntity
    {
        public string tName { get; set; }
        public double tValue { get; set; }
        public int fTagId { get; set; }
        public string date { get; set; }
    }

我是否只添加 PartitionKey、RowKey、eTag 等属性?例如 public string PartitionKey { get;放; }

我不太了解继承,因此,为我指出一个合适的解释/示例代码也将不胜感激。

最佳答案

我自己一直在迁移一些遗留代码。 Azure.Storage.Tables 遵循略有不同但有所改进的范例来处理 CosmosDB 和 Azure 表。您的表实体类不是继承 TableEntity,而是实现 ITableEntity,正如您提到的,它要求您添加 RowKey、PartitionKey、ETag 和 Timestamp 属性。

除了表实体实现之外,还有其他更改。 This article有一些很好的信息以及使用 ITableEntity 的演练。

关于此的 Microsoft 信息不太有帮助,特别是对于将现有代码从 TableEntity 迁移到 ITableEntity 而言。 Here's that documentation .

关于c# - Microsoft.Azure.Cosmos.Tables 到 Azure.Data.Tables 迁移 : TableEntity Inheritance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74693804/

相关文章:

c# - 了解 Asp.net Web 服务

c# - xamarin 'System.Object' 未定义或导入

提取 gmail、yahoomail 和 AOL 联系人的 c# 库

azure - 如何将 Azure Functions 返回值绑定(bind)到输出?

Azure WCF 访问磁盘文件

java - 使用编码 URL 删除 Azure Blob - Java

c# - 禁止 dapper.rainbow 在插入时使用 ID

azure - Azure Data Lake 是否仅临时存储分析数据?

batch-file - Kudu 部署后命令未运行

linux - 如何将文件从本地计算机传输到 Azure 容器内的虚拟文件夹(使用 blobxfer)