2012-04-06 72 views
1

我正在尝试将订单实体添加到Azure表。当我添加实体时,它只会添加分区键和行键的值。任何帮助深表感谢。这是我的代码。未将实体添加到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(); 

回答

4

您需要改用公共领域的性质。

+0

非常感谢!我现在就试试,不知道我是怎么忘记的,欢呼 – StevenR 2012-04-06 13:37:09

2

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

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