批量插入使用循环添加到windows azure中的表存储



我正在尝试在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);

上出现错误

请帮助。

我已经解决了这个问题。将windows azure工具(包括模拟器)更新到最新版本。截至目前,它的版本是2.0

相关内容

  • 没有找到相关文章

最新更新