假设我有:
using (TransactionScope scope = new TransactionScope())
{
if (IndexExists(index.RowKey))
DeleteIndex(index.RowKey); //deletes using TableOperation.Delete
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference(Const.IndexTable);
TableOperation insertOperation = TableOperation.Insert(index);
table.Execute(insertOperation);
}
我想要的是:如果插入失败,删除应该被撤消。这是正确的交易方式吗?一切都发生在同一个分区/表中。还有事务的其他限制是什么,我在某处读到事务中可以存储不超过 4 Mb,这仍然正确吗?