Data Storage in the Live Framework

There are several ways to associate data with a DataEntry in the Live Framework:

  • Attribute Extension
  • Element Extension
  • Media Resource
  • User Data
  • Syndication Link
  • Summary

This post is based on this thread on the MSDN forums.

Attribute Extension

Attribute extensions are a feature of the Feed Sync specification that can be used to add a user-defined attribute to any element in the Atom feed. The following is an example fragment of an Atom feed when an attribute extension added to a data entry:

<entry bird="Emu">

In this example, the added attribute is named bird and its value is Emu.

Attribute extensions are accessed through the AttributeExtensions property of the Resource class:

public Dictionary<XmlQualifiedName,String> AttributeExtensions { get; }

The attribute extensions can be accessed using standard Dictionary methods on the AttributeExtensions property. Attribute extensions are fairly easy to use and appear useful for storing relatively small quantities of data.

Element Extension

Element extensions are a feature of the Feed Sync specification that can be used to add a user-defined element under any parent element on an Atom feed. The following is an example fragment of an Atom feed when an element extension has been added to a data entry:

     <Bird xmlns=  xmlns:i="">

In this example, the entire Bird element (except the namespace definitions) is user-defined and can contain any valid XML.

Element extensions are accessed through the ElementExtensions property of the Resource class:

public List<ResourceMarkupExtension> ElementExtensions { get; }

Simple data can be added as an element extension by creating a ResourceMarkupExtension object and using standard List methods on the ElementExtensions property. It is also possible to use Data Contract serialization to serialize and deserialize an object into an element extension. Element extensions are slightly harder to use than attribute extensions but allow for much richer form of structured content.

Media Resource

Media resources allow arbitrary data to be stored as a blob and associated with a data entry containing its metadata. Although referred to as media resources there is no restriction on the type of data contained in media resources.

Media resources are uploaded using the Add and AddAsync methods of the DataEntryCollection class, for example:

public DataEntry Add(Stream mediaResource, String slug);

where slug is a string used to identify the media resource on the feed. It could, for example, be the filename the stream is attached to.

Media resources are downloaded using the ReadMediaResource or ReadMediaResourceAsync methods of the DataEntry class, for example:

public void ReadMediaResource(Stream destination);

Media resources appear to be a powerful facility for associating large amounts of data to a feed. An obvious use, for example, is adding images to a feed as media resources.

User Data

User data can also be added directly to a data entry where it is serialized into user-data elements managed by the live operating environment. The Live Framework uses the JSON Data Contract serializer to serialize this data.

User data is accessed on a data entry using the GetUserEntry<T> and SetUserData<T> methods of the DataEntryResource class, namely:

public T GetUserData<T>();
public void SetUserData<T>(T userData);

where T is a serializable user-defined class.

User data seems to be pretty similar in form and function to element extensions.

Syndication Link

Syndication links can be used to associate other feeds with a data entry.

A syndication link is created using a SyndicationLink constructor such as:

public SyndicationLink( Uri uri, string relationshipType, string title, string mediaType, long length );

and associating this syndication link with the data entry through the following Resource property:

public List<SyndicationLink> Links { get; }

Syndication links appear trivial to use but also look pretty interesting for creating interesting webs of interleaved data.


Summary data simply refers to use of the Summary property of the data entry for storing text data.

The Summary property of the Resource class is defined as:

public string Summary { get; set; }

Summary data is utterly trivial to use and could be useful if the summary text essentially comprises the content of the data entry.

To Do

The usability statements above are fairly banal and would be much more helpful if I had put any kind of quantification regarding both queryability and performance. Hopefully, I will get round to that sooner or later.

Technorati Tags:


About Neil Mackenzie

Cloud Solutions Architect. Microsoft
This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to Data Storage in the Live Framework

  1. Jamie says:

    Neil,This is really really useful, cheers. I’d like to know more about a syndication link; what are its typical uses? What do you mean by "interleaved data"?Bookmarked:

  2. Neil says:

    Jamie -Thanks for your comment.I really don’t know any more about syndication links than what I’ve written here and what Rajan Dwivedi wrote in the "On Handling Data" thread I based this on. I believe that the most basic use is allowing you to associate one or more other data feeds with a data entry. You could, for example, have a data feed containing a list of blog entries each of which has a syndication link to separate data feeds containing the comments. Another example would be having a data feed containing time-series summary financial data, each data entry of which linked to a data feed containing raw daily data, each entry of which linked to a data feed containing data entries comprising the components making up the daily data. Now it could be that my understanding is wrong and syndication links are really meant for something else but I suspect they could at least be used for this.I probably should not have used the word "interleaved" but by then it was late on a friday evening. My idea with that sentence was to convey the idea that it should be possible to create very complex webs/meshes (data structures) linking data entries to data feeds and on to data entries and so on. If you think of a data feed as being a one dimensional structure then the ability to link a data entry to another feed gives you a two dimensional view of the underlying data. As I pointed out in the examples in the previous paragraph you could build very complex data structures where each data feed is essentially an index into the data.Anyway, I hope I am not misleading anyone with my statements on syndication link because I have never used them – although their use appears trivial – but if my understanding is correct they could be very useful. I really should try using them before discussing them further.

  3. Vikas says:

    Neil ,Thanks for your useful blogging, this is great for the larger community and your contribution is grealy appreciated. Your blog post has already been tagged to our Live Framework Forums. I tagged it to as well.Keep writing great stuff!Thanks,Vikas AhujaForums:

  4. Jamie says:

    Neil,I like the blog comment analogy and if you’re right then I agree – syndication links could be very useful indeed!! -Jamie

  5. Oran says:

    Interesting ideas for how to use syndications links. Syndication links are the "foreign keys" of the feed world and are therefore useful for all sorts of things. I like that they allow you to annotate them with additional bits of metadata such as title, relationshipType, mediaType, and length. One thing to keep in mind if you use syndication links for referential integrity is that feeds are the unit of synchronization. So if you make links across feeds, you run the risk that one feed will synchronize before another, resulting in links that temporarily point to nonexistent resources. If you need to ensure that links always point to existing resources, the linked resources will need to live in the same feed.

  6. Vikas says:

    Bill has started to explore Live Framework and as one of his first posts – he mentions about custom resource types: two blog posts!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s