我正在尝试从Windows Azure中的对象列表到表存储进行批量插入。
我现在正在使用存储模拟器。 我收到这个错误:
“意外的操作响应代码”。
我试图搜索遇到类似问题但无济于事的人。
我的密钥是这样设置的:
PartitionKey = "projects" + CompanyID.toString();
RowKey = ProjectID.toString();
它插入如下:
foreach (vProject item in projectList)
{
TableOperation retrieveOperation = TableOperation.Retrieve<mMultipleSave.ViewProjectEntity>("projects" + CompanyID.toString(), item.ProjectID.ToString());
TableResult retrievedResult = table.Execute(retrieveOperation);
if (retrievedResult.Result != null)
{
mMultipleSave.ViewProjectEntity updateEntity = (mMultipleSave.ViewProjectEntity)retrievedResult.Result;
if (!item.isProjectArchived)
{
//update entity in table storage
updateEntity.ProjectClient = item.ClientName;
updateEntity.ProjectCompany = item.Company;
updateEntity.ProjectName = item.ProjectName;
batchUpdateOperation.Replace(updateEntity);
}
else {
//delete project in table storage if it is archived in the database
batchDeleteOperation.Delete(updateEntity);
}
}
else //if it does not exist in table storage insert
{
mMultipleSave.ViewProjectEntity entity = new mMultipleSave.ViewProjectEntity(CompanyID, item.ProjectID);
entity.ProjectClient = item.ClientName;
entity.ProjectCompany = item.Company;
entity.ProjectName = item.ProjectName;
batchInsertOperation.Insert(entity);
}
}
if (batchInsertOperation.Count > 0)
table.ExecuteBatch(batchInsertOperation);
if (batchUpdateOperation.Count > 0)
table.ExecuteBatch(batchUpdateOperation);
if (batchDeleteOperation.Count > 0)
table.ExecuteBatch(batchDeleteOperation);
table.ExecuteBatch(batchInsertOperation);
请帮忙。
答案 0 :(得分:0)
我已经解决了这个问题。将包含模拟器的Windows Azure工具更新到最新版本。截至今天,它是2.0版本