更新实体中的字段(属性)

时间:2016-05-27 10:19:39

标签: azure-storage azure-table-storage

我有没有更新我实体中的某些字段? 例如,我想在实体man中更新字段名称,而不发送完整实体。 现在要更改我首先请求它的实体,并在更改字段后,我发送此实体进行更新。

1 个答案:

答案 0 :(得分:1)

是的,您可以使用合并实体插入或合并实体操作更新实体而不更新其他属性。

请参阅我们的表格存储样本here。它们展示了如何使用我们的客户端库合并实体。

以下是.NET示例的摘录,可能会有所帮助:

         // Create an instance of a customer entity. See the Model\CustomerEntity.cs for a description of the entity.
        CustomerEntity customer = new CustomerEntity("Harp", "Walter")
        {
            Email = "Walter@contoso.com",
            PhoneNumber = "425-555-0101"
        };

        // Demonstrate how to Update the entity by changing the phone number
        Console.WriteLine("2. Update an existing Entity using the InsertOrMerge Upsert Operation.");
        customer.PhoneNumber = "425-555-0105";
        customer = await InsertOrMergeEntityAsync(table, customer);

另外,请参阅合并实体插入或合并实体操作的REST API参考:

https://msdn.microsoft.com/en-us/library/azure/dd179392.aspx

https://msdn.microsoft.com/en-us/library/azure/hh452241.aspx

相关问题