Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Inserting multiple entities into Azure Table Storage as part of a batch operation
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
public void InsertOrders(CloudStorageAccount storageAccount)
{
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("orders");
TableBatchOperation batchOperation = new TableBatchOperation();
OrderEntity newOrder1 = new OrderEntity("Smith", "20150410");
newOrder1.OrderNumber = "1";
newOrder1.OrderDate = Convert.ToDateTime("20150410");
newOrder1.ShippedDate = Convert.ToDateTime("20150411");
newOrder1.Status = "shipped";
OrderEntity newOrder2 = new OrderEntity("Jones", "20150413");
newOrder2.OrderNumber = "2";
newOrder2.OrderDate = Convert.ToDateTime("20150413");
newOrder2.ShippedDate = Convert.ToDateTime("19000101");
newOrder2.Status = "pending";
batchOperation.Insert(newOrder1);
batchOperation.Insert(newOrder2);
table.ExecuteBatch(batchOperation);
}
@AvgustPol

This comment has been minimized.

Copy link

@AvgustPol AvgustPol commented Jul 9, 2020

thanks <3

@marceloatg

This comment has been minimized.

Copy link

@marceloatg marceloatg commented Aug 10, 2020

Thanks for saving me time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment