Skip to content

Instantly share code, notes, and snippets.

@gbellmann
Created April 13, 2015 22:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbellmann/b90380c3127218b597b3 to your computer and use it in GitHub Desktop.
Save gbellmann/b90380c3127218b597b3 to your computer and use it in GitHub Desktop.
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
Copy link

thanks <3

@marceloatg
Copy link

Thanks for saving me time!

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