Azure Table 存储 - GUID 返回为空

Azure Table Storage - GUID coming back empty

我正在尝试从 table 中检索一些实体。我能够成功取回字符串,但是当我尝试获取 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);

如何在 table 存储中获取正确的 GUID 值?跟TableEntity.ReadEntity有关系吗?

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

@RotemVaron,您可以使用函数 TableEntity.ReadEntity Method (IDictionary<String, EntityProperty>, OperationContext) to deserializes the entity using the specified IDictionary<TKey, TValue> that maps property names to typed EntityProperty 值。然后,从 EntityProperty 对象获取 Guid 值。

有一个 blog 显示了示例 Reading existing entities,它遍历实体中包含 GuidValue 的属性。