Tag Archives: framework

The great data context in the cloud

No, I’m not posting about the ‘death’ of LINQ to SQL, I’m talking about the live framework SDK! I’ve been meandering my way through the MSDN documentation and samples for the framework to check out what’s coming. What excites me the most about what I can see in the MSDN doco is the fact that as the title suggests, using the .Net libraries your mesh becomes like a data context that exists not to interface with your database, but with a datasource either in your mesh, or locally on your machine.

One of the great things here is that you don’t need to care (well, not much…) whether that source is local or remote! With a little bit of ye olde factory pattern, you can get yourself what is called a LiveOperatingEnvironment to work against. As far as I can see, the only downside is the lack of notifications on mesh object changes.

Taking this a step further, we can assume that if the LiveOperatingEnvironment looks like a datacontext, the objects we obtain from queries run against them maintain some sense of state. This seems to hold true thanks to the presence of the Load() and Update() methods on the abstract base class of the mesh objects known as LiveItem. Continuing on the data context path, we can say that to obtain an item from our mesh we can do something along the lines of…

var myMeshObject = (from meshObjects in myLiveOperatingEnvironment.CreateQuery<MeshObject>

select meshObjects).First();

Notice the main difference here from your regular LINQ query is that we’re calling the generic CreateQuery<T> method that lives in our LiveOperatingEnvironment class. This method appears to be the granddaddy of all live queries in the .Net libraries. The generic restrictions mean that you can query and LiveItem inheriting classes – which means just about anything. It returns an instance of the LiveQuery class, which is the object that inherits the IQueryable and IEnumerable interfaces, providing all our LINQ goodness. Moving on from here, if I wanted to say, update the title of my meshObject I would do something along the lines of…

myMeshObject.Resource.Title = "Live Framework SDK Information";
myMeshObject.Update();

It’s so simple! Additional good news is – if you haven’t quite got your head quite around LINQ yet, and you’re keen on making use of the Live Framework there’s also other options. These queries can be run as RESTful operations, through the use of either an ATOMPub library or a JavaScript library. There are some differences in what’s made available, however I haven’t delved much into the JS or ATOM libraries so I won’t comment too much on them here but there’s no reason you can’t go check out the SDK doco yourself over at MSDN!

Advertisements