【问题标题】:Remove columns from Azure Table Storage从 Azure 表存储中删除列
【发布时间】:2012-05-25 07:11:17
【问题描述】:

这是我用来从表存储中读取实体的 sn-p 代码:

public void OnReadingEntity(object sender, ReadingWritingEntityEventArgs args)
    {
        XNamespace AtomNamespace = "http://www.w3.org/2005/Atom";
        XNamespace AstoriaMetadataNamespace = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

        GenericEntity entity = args.Entity as GenericEntity;
        if (entity == null)
        {
            return;
        }

        // read each property, type and value in the payload   
        var properties = args.Entity.GetType().GetProperties();
        var q = from p in args.Data.Element(AtomNamespace + "content")
                                .Element(AstoriaMetadataNamespace + "properties")
                                .Elements()
                where properties.All(pp => pp.Name != p.Name.LocalName)
                select new
                {
                    Name = UnescapePropertyName(p.Name.LocalName),
                    IsNull = string.Equals("true", p.Attribute(AstoriaMetadataNamespace + "null") == null 
                        ? null 
                        : p.Attribute(AstoriaMetadataNamespace + "null").Value, StringComparison.OrdinalIgnoreCase),
                    TypeName = p.Attribute(AstoriaMetadataNamespace + "type") == null 
                        ? null 
                        : p.Attribute(AstoriaMetadataNamespace + "type").Value,
                    p.Value
                };

        foreach (var dp in q)
        {
            entity[dp.Name] = GetTypedEdmValue(dp.TypeName, dp.Value, dp.IsNull);
        }
    }

不幸的是,这段代码将返回一些存在于我已删除的实体中的属性。

谁能解释这是为什么?

【问题讨论】:

标签: azure azure-table-storage data-transform


【解决方案1】:

Azure 表存储没有您在关系数据库中习惯使用的列。除了必填列之外,每一行都可以有完全不同的属性。

当您说“仍然显示”时,我假设这正是您使用的工具呈现数据的方式,让您认为它就像一个关系表。

请参阅 http://msdn.microsoft.com/en-us/magazine/ff796231.aspx 了解一些良好的技术背景。

【讨论】:

  • 嗨,托德,你说得完全正确,我写这篇文章很匆忙,做了一个编辑,所以它更有意义。
  • 啊,这更有意义。您使用的是存储模拟器还是实时服务?如果它是模拟器,您可能会看到这里描述的问题stackoverflow.com/questions/3076499/…
猜你喜欢
  • 2016-06-11
  • 2012-02-06
  • 2017-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-09
  • 2021-11-02
  • 1970-01-01
相关资源
最近更新 更多