fre*_*ed_ 1 c# azure azure-storage azure-table-storage azure-sdk-.net
我正在尝试使用asure sdk 1.6的新upsert功能(针对存储模拟器).
但我只是设法使更新工作.当我尝试为一个新的rowkey upsert时,我得到了resource not found异常.
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);
Run Code Online (Sandbox Code Playgroud)
如果我把AddObject它插入但不是更新.由于新的sdk,我一直在考虑能够在一个动作中做到这两点.
它只能用于真正的Azure存储.开发存储不支持Upsert操作.此外,您必须将tableServiceContext的IgnoreResourceNotFoundException属性设置为true.
| 归档时间: |
|
| 查看次数: |
1039 次 |
| 最近记录: |