从Azure表存储中删除列

问题描述 投票:0回答:1

这是我用来从表存储中读取实体的代码片段:

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个回答
1
投票

Azure表存储不包含您在关系数据库中惯用的列。除了强制列之外,每行可以具有完全不同的属性。

[当您说“还在显示”时,我假设这只是您使用的工具呈现数据的方式,使您认为它像关系表一样。

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

© www.soinside.com 2019 - 2024. All rights reserved.