如何对 Azure Storage Table 进行批量操作?
How to do batch operation on Azure Storage Table?
我想将多个实体插入 azure table 使用 Table 操作
我将所有数据作为列表获取,我只想将这些详细信息保存到 table。
var registrationDescriptionsList = new List<RegistrationDescription>(allRegistrations);
foreach(var retrivedatafromlist in registrationDescriptionsList)
{
batchOperation.Add(TableOperation.Insert(retrivedatafromlist));
}
我找到了解决方案。请找到代码。
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);
我想将多个实体插入 azure table 使用 Table 操作
我将所有数据作为列表获取,我只想将这些详细信息保存到 table。
var registrationDescriptionsList = new List<RegistrationDescription>(allRegistrations);
foreach(var retrivedatafromlist in registrationDescriptionsList)
{
batchOperation.Add(TableOperation.Insert(retrivedatafromlist));
}
我找到了解决方案。请找到代码。
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);