Created
January 6, 2020 18:42
-
-
Save ealsur/3d18f0cbc6258e8f27565a8581790e45 to your computer and use it in GitHub Desktop.
TransactionalBatch - Error view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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