Windows Azure Table Services - Advanced Properties and Table Schema

I have an object that, in addition to several common properties, contains a list of advanced properties stored as (Name, Value) pairs of strings in the collection. I should probably mention that these extended properties vary widely from instance to instance and that they need to be specified only for each instance (there will be no requests for extended properties, for example, to find all instances with a specific name (Name, Value)). I am studying how I can save this object using Windows Azure Table Services. With the specific approach that I'm testing now, I am concerned that performance degradation may occur over time as the application uses more different extended property names.

If I saved this object in a typical relational database, I would probably have two tables to support this scheme: the first will contain the object identifier and its general properties, and the second will refer to the object identifier and use the EAV modeling line style for storing extended (name, value) pairs, one for each row.

Since tables in Windows Azure already use the EAV model, I am considering custom serializing my object so that the extended properties are preserved as if they were declared at compile time for the object. I can use the read and write-events provided by the DataServiceContext to accomplish this.

private void OnReadingEntity(object sender, ReadingWritingEntityEventArgs e)
{
    MyEntity Entry = e.Entity as MyEntity;

    if (Entry != null)
    {
        XElement Properties = e.Data
            .Element(Atom + "content")
            .Element(Meta + "properties");

        //select metadata from the extended properties
        Entry.ExtendedProperties = (from p in Properties.Elements()
                          where p.Name.Namespace == Data && !IsReservedPropertyName(p.Name.LocalName) && !string.IsNullOrEmpty(p.Value)
                          select new Property(p.Name.LocalName, p.Value)).ToArray();
    }
}

private void OnWritingEntity(object sender, ReadingWritingEntityEventArgs e)
{
    MyEntity Entry = e.Entity as MyEntity;

    if (Entry != null)
    {
        XElement Properties = e.Data
            .Element(Atom + "content")
            .Element(Meta + "properties");

        //add extended properties from the metadata
        foreach (Property p in (from p in Entry.ExtendedProperties 
                                where !IsReservedPropertyName(p.Name) && !string.IsNullOrEmpty(p.Value)
                                select p))
        {
            Properties.Add(new XElement(Data + p.Name, p.Value));
        }
    }
}

, , , Windows Azure.

, , ?

:

  • . , (, ), , , XML- .

  • , , xml, OnReadingEntity, , - ( , ). , .

? , , . , Windows Azure Tables ? , . .

+3
1

SQL Express . , ... , , .

+4

Source: https://habr.com/ru/post/1750827/


All Articles