我试图获取一个实体,增加属性值之一,然后更新它。这是我的代码段
var t = cc.GetTableReference("tableName");
var query = new TableQuery();
query.Where("PartitionKey eq 'myPartitionKey'");
var res = t.ExecuteQuery(query); //this command executes succesfully
var ent = res.FirstOrDefault();
var num = ent.Properties["num"].Int64Value.Value;
ent.Properties["num"].Int64Value = num + 1;
var updateOperation = TableOperation.Replace(ent);
t.Execute(updateOperation, null,new OperationContext { UserHeaders = new Dictionary<string, string> { { "If-Match", ent.ETag } } });
如果删除OperationContext,它将成功更新。
t.Execute(updateOperation);
有人知道导致错误的原因吗?任何帮助将不胜感激
答案 0 :(得分:0)
肇兴的上述评论是正确的答案