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>
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";