Azure表存储 - GUID返回空

时间:2016-07-15 22:38:09

标签: azure deserialization azure-table-storage azure-tablequery

我正在尝试从表中检索某些实体。我成功地能够返回字符串,但是当我尝试获取GUID时,它返回空(全为零)。

[DataContract]
public class myEntity : TableEntity
{
    [DataMember(Name = "ID")]
    public Guid Id { get; set; }

    [DataMember(Name = "Name")]
    public string Name { get; set; }

    [DataMember(Name = "City")]
    public string City { get; set; }

}

...

var storageAccount = CloudStorageAccount.Parse(conStr);
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference(tblName);
TableQuery<myEntity> query = new TableQuery<myEntity>().Where(string.Empty);

如何在表存储中获取正确的GUID值?它与TableEntity.ReadEntity有关吗?

2 个答案:

答案 0 :(得分:4)

我不认为获取GUID属性需要额外的操作。如果确实存在于该表的GUID属性中的值,您是否已通过其他工具进行交叉检查?

答案 1 :(得分:1)

@RotemVaron,您可以使用函数TableEntity.ReadEntity Method (IDictionary<String, EntityProperty>, OperationContext)使用指定的IDictionary<TKey, TValue>来反序列化实体,该Reading existing entities将属性名称映射到类型EntityProperty值。然后,从EntityProperty对象获取Guid值。

有一个blog显示示例GuidValue,它从实体遍历属性包括<div class="container-fluid"> <div class="jumbotron"> <div class="container"> <div class="navbar"> <a href="#" class="brand">Brand</a> <nav class="pull-xs-right"> <ul class="nav"> <li class="nav-item"><a href="#" class="nav-link">Home</a> </li> <li class="nav-item"><a href="#" class="nav-link">About Us</a> </li> <li class="nav-item"><a href="#" class="nav-link">Services</a> </li> <li class="nav-item"><a href="#" class="nav-link">Blog</a> </li> <li class="nav-item"><a href="#" class="nav-link">Contact Us</a> </li> </ul> </nav> </div> <!-- end navbar inner --> </div> <!-- end navbar --> <div class="hero-unit-inner text-xs-center"> <h1>Text</h1> <h4>Text </h4> <a href="#" class="btn">Get Started</a> <a href="#">Learn More</a> <img src="img/browser.png" /> </div> </div><!-- end jumbotron --> </div><!-- end of container -->