简体   繁体   English

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

[英]Microsoft.Azure.Cosmos.Tables to Azure.Data.Tables migration: TableEntity Inheritance

I am trying to migrate some legacy code from Microsoft.AzureCosmos.Tables to Azure.Storage.Tables.我正在尝试将一些遗留代码从 Microsoft.AzureCosmos.Tables 迁移到 Azure.Storage.Tables。 The TableEntity class is sealed in Azure.storage.Tables, so how do I fix this? TableEntity class 被密封在 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; }
    }

Do I just add the PartitionKey, RowKey, eTag, etc properties?我是否只添加 PartitionKey、RowKey、eTag 等属性? Eg public string PartitionKey { get; set; }例如public string PartitionKey { get; set; } public string PartitionKey { get; set; } public string PartitionKey { get; set; } ? public string PartitionKey { get; set; }

I don't really understand inheritance, so pointing me at a decent explanation/sample code would also be appreciated.我真的不明白 inheritance,所以指出我一个体面的解释/示例代码也将不胜感激。

I've been migrating some legacy code myself.我一直在自己迁移一些遗留代码。 Azure.Storage.Tables follows a slightly different albeit improved paradigm for working with CosmosDB and Azure tables. Azure.Storage.Tables 在使用 CosmosDB 和 Azure 表时遵循稍微不同但有所改进的范例。 Instead of inheriting TableEntity, your table entity classes implement ITableEntity, which as you mentioned requires you to add the RowKey, PartitionKey, ETag and Timestamp properties.您的表实体类不是继承 TableEntity,而是实现 ITableEntity,正如您提到的那样,它需要您添加 RowKey、PartitionKey、ETag 和 Timestamp 属性。

There are other changes besides the table entity implementation.除了表实体实现之外还有其他变化。 This article has some good information with a walkthrough using ITableEntity. 本文提供了一些很好的信息,其中包含使用 ITableEntity 的演练。

The Microsoft information on this is a little less helpful, especially for migrating existing code from TableEntity to ITableEntity. Microsoft 关于此的信息帮助不大,尤其是对于将现有代码从 TableEntity 迁移到 ITableEntity。 Here's that documentation . 这是该文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure.Data.Tables 中的实体拦截器 - Entity interceptors in Azure.Data.Tables 如何使用 Azure.Data.Tables 列出所有表? - How to list all tables with Azure.Data.Tables? Azure.Data.Tables 仅查询下一条记录(限制/取 1?) - Azure.Data.Tables querying only next record (limit/take 1?) 如何使用 Azure.Data.Tables TableClient 依赖注入多表? - How to use Azure.Data.Tables TableClient with dependency injection multiple tables? Azure.Data.Tables C# SDK 查询时间戳返回零结果 - Azure.Data.Tables C# SDK query Timestamp returning zero results Azure 管道中的数据工厂重命名表 - Azure Data Factory Rename Tables in Pipeline 无法从 Azure Function 连接到 Azure Cosmos DB。 获取“Microsoft.Azure.Cosmos.Direct:Object 引用未设置为 object 的实例 - Unable to Connect from Azure Function to Azure Cosmos DB. Getting "Microsoft.Azure.Cosmos.Direct: Object reference not set to an instance of an object Azure Databricks - 与考拉一起读书的桌子 - Azure Databricks - reading tables with koalas 如何在 Azure Cosmos DB 中按日期对数据进行分组? - How to group data by date in Azure Cosmos DB? 表不再出现在连接列表中 - Azure Data Studio 1.41、Azure SQL 服务器数据库 - Tables No Longer Appear in Connections List - Azure Data Studio 1.41, Azure SQL Server Database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM