Created
April 13, 2015 22:17
-
-
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
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
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks <3