Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TransactionalBatch - Error view
// Parent's birthday!
parent.Age = 31;
// Naming two childs with the same name, should abort the transaction
ChildClass anotherChild = new ChildClass(){ Id = "The Child", ParentId = parent.Id, PartitionKey = partitionKey };
TransactionalBatchResponse failedBatchResponse = await container.CreateTransactionalBatch(new PartitionKey(partitionKey))
.ReplaceItem<ParentClass>(parent.Id, parent)
.CreateItem<ChildClass>(anotherChild)
.ExecuteAsync();
using (failedBatchResponse)
{
if (!failedBatchResponse.IsSuccessStatusCode)
{
TransactionalBatchOperationResult<ParentClass> parentResult = failedBatchResponse.GetOperationResultAtIndex<ParentClass>(0);
// parentResult.StatusCode is 424
TransactionalBatchOperationResult<ChildClass> childResult = failedBatchResponse.GetOperationResultAtIndex<ChildClass>(1);
// childResult.StatusCode is 409
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment