Reputation: 2902
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; }
?
I don't really understand inheritance, so pointing me at a decent explanation/sample code would also be appreciated.
Upvotes: 2
Views: 1287
Reputation: 61
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.
Upvotes: 2