public override void Apply(TransactionalBatch transactionalBatch, PartitionKeyPath partitionKeyPath) { var jObject = ToEnrichedJObject(partitionKeyPath); // has to be kept open stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(jObject))); var options = new TransactionalBatchItemRequestOptions { EnableContentResponseOnWrite = false }; transactionalBatch.CreateItemStream(stream, options); }
async Task CreateOrUpdateInBatch(TransactionalBatch batch) { if (etag == null) { batch.CreateItemStream(ToStream(value)); } else { var options = new TransactionalBatchItemRequestOptions { IfMatchEtag = etag }; batch.ReplaceItemStream(TransactionEntityId, ToStream(value), options); } var response = await batch.ExecuteAsync().ConfigureAwait(false); if (!response.IsSuccessStatusCode) { throw new Exception(response.ToString()); } etag = response.Last().ETag; }
public override void Apply(TransactionalBatch transactionalBatch, PartitionKeyPath partitionKeyPath) { transactionalBatch.CreateItemStream(streamPayload, options); }