【问题标题】:Entity not being added to Azure Table but row key and partition key are beind added correctly实体未添加到 Azure 表,但行键和分区键已正确添加
【发布时间】:2012-04-06 12:41:37
【问题描述】:

我正在尝试将订单实体添加到 Azure 表。当我添加实体时,它只添加分区键和行键的值。任何帮助深表感谢。这是我的代码。

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

然后在一个单独的类中

        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();

【问题讨论】:

    标签: c# azure azure-storage azure-table-storage


    【解决方案1】:

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

    【讨论】:

    • 非常感谢!我现在就试试,不知道我怎么忘记了,干杯
    【解决方案2】:

    Mark Rendle 是正确的,只支持公共属性而不支持字段。

    因为我在 Microsoft 客户端上遇到了限制,所以我编写了一个备用 Azure 表存储客户端 Lucifure Stash,其中包含许多高级抽象。 Lucifure Stash,支持 > 64K 的数据列、列表、数组、枚举、序列化、变形、公共和私有属性和字段等。它免费供个人使用,可以从http://www.lucifure.com 或通过 NuGet.com 下载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-09
      相关资源
      最近更新 更多