簡體   English   中英

實體未添加到 Azure 表,但正確添加了行鍵和分區鍵

[英]Entity not being added to Azure Table but row key and partition key are beind added correctly

我正在嘗試將訂單實體添加到 Azure 表中。 當我添加實體時,它只添加分區鍵和行鍵的值。 任何幫助深表感謝。 這是我的代碼。

class OrderEntity : TableServiceEntity
{
    public int customerID;
    public int productID;
    public Double price;
    public String status;
}

然后在一個單獨的 class

        OrderEntity order = new OrderEntity();
        order.customerID = retrievedCustomer.id;
        order.productID = selectedProduct.id;
        order.price = Convert.ToDouble(selectedProduct.price);
        order.PartitionKey = retrievedCustomer.id.ToString();
        order.RowKey = counter.ToString();
        order.status = "Processing Order";

        serviceContext.AddObject("orders", order);

        // Submit the operation to the table service
        serviceContext.SaveChangesWithRetries();

您需要使用屬性而不是公共字段。

Mark Rendle 是正確的,只支持公共屬性,不支持字段。

因為我在 Microsoft 客戶端上遇到了限制,所以我編寫了一個備用的 Azure 表存儲客戶端 Lucifure Stash,它具有許多高級抽象。 Lucifure Stash,支持大於 64K 的數據列、列表、arrays、枚舉、序列化、變形、公共和私有屬性和字段等。 它是免費供個人使用的,可以從http://www.lucifure.com或通過 NuGet.com 下載。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM