Question

I have the following code which tries to update the following entity class which happens to contain a DateTimeOffset, This however throws an NotImplementedException. Has anybody else seen this?

[System.Data.Services.Common.DataServiceKey("PartitionKey", "RowKey")]
public sealed class CollectorStateEntity : TableEntity
{
    public CollectorStateEntity()
    {}

    public CollectorStateEntity(string collectorName, string tenantInstance)
    {
        this.PartitionKey = tenantInstance;
        this.RowKey = collectorName;
    }

    public DateTimeOffset StartingTime { get; set; }
}


    public static void UpdateCollectorStateEntityInTableStore(string connectionString, string tableName, string tenantInstance, string collectorName)
    {
        // Get Access to the table
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
        TableServiceContext serviceContext = tableClient.GetTableServiceContext();


        CollectorStateEntity specificEntity =
            (from e in serviceContext.CreateQuery<CollectorStateEntity>(tableName)
             where e.PartitionKey == tenantInstance && e.RowKey == collectorName
             select e).FirstOrDefault();

        specificEntity.StartingTime = DateTimeOffset.Parse("01/27/2014 10:35:00 AM -08:00");

        serviceContext.UpdateObject(specificEntity);
        serviceContext.SaveChangesWithRetries();
    }

When trying to do an update when calling UpdateCollectorStateEntityInTableStore I get a StorageException with Message = "NotImplemented". Do I have any other options other than serializing\deserializing DateTimeOffset to string ?

Was it helpful?

Solution

As mentioned by Brendan, because DateTimeOffset is not a supported data type in Azure Table Storage, you're getting this error. A few things you could do are:

  1. As you mentioned, you could use a String or DateTime type property instead of DateTimeOffset.
  2. Another alternative would be to do the serialization/deserialization yourself. For this you would need to override ReadEntity and WriteEntity methods.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top