简体   繁体   中英

How to do batch operation on Azure Storage Table?

I want to insert Multiple Entities into azure table Using Table Operation

I got all data as a List and I just want to save these details into table.

var registrationDescriptionsList = new List<RegistrationDescription>(allRegistrations);

foreach(var retrivedatafromlist in registrationDescriptionsList)
{

     batchOperation.Add(TableOperation.Insert(retrivedatafromlist));

}

I found the solution. Please find the code.

TableBatchOperation batchOperation = new TableBatchOperation();

foreach (var retrivedatafromlist in registrationDescriptionsList)
{
     NotificationHubServiceBus NhsbObj = new NotificationHubServiceBus();

     var tags = "";

     foreach (var a in retrivedatafromlist.Tags)
     {
         tags = tags + a;
     }

     NhsbObj.PartitionKey = "Sample";
     NhsbObj.RowKey = retrivedatafromlist.RegistrationId;
     NhsbObj.RegistrationId = retrivedatafromlist.RegistrationId;
     NhsbObj.ExpirationDate = retrivedatafromlist.ExpirationTime.ToString();
     NhsbObj.ETag = retrivedatafromlist.ETag;
     NhsbObj.Tags = tags;

     batchOperation.Insert(NhsbObj);
}

table.ExecuteBatch(batchOperation);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM