我有以下代码尝试更新碰巧包含DateTimeOffset的以下实体类,但是会抛出NotImplementedException。有没有人见过这个?
[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();
}
在调用UpdateCollectorStateEntityInTableStore时尝试进行更新时,我得到一个MessageException,其中Message =“NotImplemented”。除了将DateTimeOffset序列化/反序列化为字符串?
之外,我还有其他选择吗?答案 0 :(得分:2)
正如Brendan所提到的,因为DateTimeOffset
在Azure表存储中不是受支持的数据类型,所以您收到此错误。你可以做的一些事情是:
String
或DateTime
类型的属性,而不是DateTimeOffset
。ReadEntity
和WriteEntity
方法。