I am trying to do a batch insert from a list of objects to table storage in Windows Azure.
I am using the storage emulator for now. I get this error:
"Unexpected response code for operation".
I tried to search for anyone who encountered similar problems but to no avail.
My keys are setup this way:
PartitionKey = "projects" + CompanyID.toString();
RowKey = ProjectID.toString();
It is inserted like this:
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);
It gets an error on table.ExecuteBatch(batchInsertOperation);
Please help.