我正在尝试使用 asure sdk 1.6 的新 upsert 功能(针对存储模拟器)。
但我只是设法让更新工作。当我尝试更新插入新的行键时,出现资源未找到
异常。
var context = new TableServiceContext(_cloudStorageAccount.TableEndpoint.ToString(), _cloudStorageAccount.Credentials)
{
MergeOption = MergeOption.NoTracking,
ResolveType = (unused) => typeof(SmartTableServiceEntity)
};
context.AttachTo(tableName, smartEntity, "*");
context.UpdateObject(smartEntity);
context.SaveChangesWithRetries(SaveChangesOptions.ReplaceOnUpdate);
如果我放置AddObject
,它会执行插入操作,但不会执行更新操作。
我想借助新的 sdk,能够一次完成这两件事。
最佳答案
它仅适用于真正的 Azure 存储。开发存储不支持Upsert操作。 此外,您还必须将 tableServiceContext 的 IgnoreResourceNotFoundException 属性设置为 true。
关于c# - Azure 表存储 sdk 1.6 Upsert 未插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8587845/