![](/img/trans.png)
[英]Azure Function to Update Table Storage entity - CloudTable.Execute not found
[英]How do I update an entity in Azure Table Storage?
如何更新Azure表中的單個實體?
閱讀: https : //docs.microsoft.com/zh-cn/dotnet/api/microsoft.windowsazure.storage.table.tableoperation.merge?view=azure-dotnet
它只是簡單地說它合並了實體。
它如何合並?
哪些屬性被覆蓋,哪些不被覆蓋?
值為空的實體屬性是否不會更新?
是的,不,也許嗎?
要了解Merge
操作的工作原理,請考慮以下示例。
假設您有一個如下實體:
PartitionKey: "PK"
RowKey: "RK"
Attribute1: "Value 1"
Attribute2: "Value 2"
現在,您要更新該實體。 您要做的就是更改Attribute1
的值,並添加一個新屬性Attribute3
。
PartitionKey: "PK"
RowKey: "RK"
Attribute1: "Value 1 (Updated)"
Attribute3: "Value 3"
使用Merge
更新實體后,生成的實體將是:
PartitionKey: "PK"
RowKey: "RK"
Attribute1: "Value 1 (Updated)"
Attribute2: "Value 2"
Attribute3: "Value 3"
總結Merge
操作:
請注意,還有“ Replace Entity
操作,該操作將原始實體替換為更新后的實體。 因此,在同一示例中,如果使用“ Replace Entity
操作更新實體,則生成的實體將是:
PartitionKey: "PK"
RowKey: "RK"
Attribute1: "Value 1 (Updated)"
Attribute3: "Value 3"
總結Replace
操作:
根據HTTP API https://docs.microsoft.com/en-us/rest/api/storageservices/merge-entity :
表服務不會保留屬性的空值。 指定具有空值的屬性等同於在請求中省略該屬性。 合並實體操作將僅更新具有非空值的屬性。
假設這也適用於C#SDK。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.