azure表存储中的事务
假设我有:azure表存储中的事务,azure,azure-table-storage,Azure,Azure Table Storage,假设我有: using (TransactionScope scope = new TransactionScope()) { if (IndexExists(index.RowKey)) DeleteIndex(index.RowKey); //deletes using TableOperation.Delete CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Connectio
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);
}
我想要的是:如果插入失败,删除应该撤消。这是正确的交易方式吗?所有事情都发生在同一个分区/表中。还有什么是事务的其他限制,我在某个地方读到,事务中存储的空间不能超过4MB,这是否仍然正确?假设需要执行操作的所有实体都具有相同的分区密钥,您可以使用Windows Azure表存储中可用的功能。正是这样。如果对事务中某个实体的操作失败,则整个事务将回滚 但是,您似乎正在删除一个实体,然后再次创建同一个实体。该场景在实体批处理事务中不起作用,因为实体在事务中只能出现一次,并且只能对实体执行一个操作。看起来您感兴趣的是替换实体。在这种情况下,您可以直接使用功能