0

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?

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Calin
  • 6,661
  • 7
  • 49
  • 80

1 Answers1

1

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.

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

  • Hi Todd, you are perfectly right, I wrote the post in a hurry, did an edit so it makes more sense. – Calin May 25 '12 at 12:28
  • 1
    Ah that makes more sense. Are you working with the storage emulator or the live service? If its the emulator you might be seeing the problem described here http://stackoverflow.com/questions/3076499/windows-azure-table-services-extended-properties-and-table-schema – Todd Whitehead May 26 '12 at 19:46