从Azure表存储中删除列 [英] Remove columns from Azure Table Storage

查看:78
本文介绍了从Azure表存储中删除列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Here is a snippet of code I am using to read entities from Table storage:

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);
        }
    }

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

Unfortunately this piece of code will return some properties that existed in entities I've deleted.

有人可以解释为什么吗?

Can someone explain why is that?

推荐答案

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

Azure table storage doesnt have columns as you're used to in relational databases. Each row can have completely different properties other than the mandatory columns.

当您说仍然显示出来"时,我假设这只是您使用的工具呈现数据的方式,使您认为它像关系表一样.

When you say "still shows Up" I'm assuming this is just the way the tool you are using is presenting the data that is making you think its like a relational table.

请参见 http://msdn.microsoft.com/en-us/magazine/ff796231.aspx 以获得一些良好的技术背景.

See http://msdn.microsoft.com/en-us/magazine/ff796231.aspx for some good technical background.

这篇关于从Azure表存储中删除列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆