我不确定这是否可行,但我正在尝试使用 C# Azure Table API 通过创建一个全新的实体并合并它来更新表存储中的属性:
// Create an object that only specifies the property to update
// (null properties are not updated)
var itemToUpdate = new TableEntity("PartitionKey", "RowKey");
itemToUpdate.DateLastAccessedUtc = DateTime.Now;
// can't do this!
//itemToUpdate.DateCreatedUtc = null;
// Attach to the item, update it, and save the changes
_dataContext.AttachTo(_dataContext.TableName, itemToUpdate, "*");
_dataContext.UpdateObject(itemToUpdate);
_dataContext.SaveChanges();
基本上,我想更新上次访问日期而不更新创建日期,但由于 DateTimes 不能为空,我不能这样做。是否可以在不两次调用表的情况下执行此操作?由于这将被频繁调用,因此如果可以避免的话,我不想在更新对象之前检索它。