简体   繁体   中英

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. The TableEntity class is sealed in Azure.storage.Tables, so how do I fix this?

    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? Eg 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.

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. 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.

There are other changes besides the table entity implementation. This article has some good information with a walkthrough using ITableEntity.

The Microsoft information on this is a little less helpful, especially for migrating existing code from TableEntity to ITableEntity. Here's that documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM