Welcome to EMC Consulting Blogs Sign in | Join | Help

SSIS Junkie

Open Space Coding – Using the SSDS REST Library

January 2009 seems to have been a good month for inaugural events and naturally the most important one was the inaugural Open Space Coding day on 31st January as arranged by Mr Alan Dean and hosted by Michelle Flynn of EMC Conchango. I was lucky enough to be able to attend the day so let me tell you a little about it.

The day was intended to be an opportunity for like-minded souls (mostly members of the alt.net community) to get together, state their interests in learning about something, and huddle around a PC banging out code. The main theme of the day was on learning through doing not learning through listening. We had three rooms available to use for the sessions and two session slots (each of which were two hours long) making a total of 6 sessions through the day. In addition we had a fourth free room where anyone not interested in the sessions going on at that time could curl up and hack away at whatever interested them.

The first task in the morning was to decide what subjects were going to be discussed; this involved us all pinning suggestions to the wall so that we could all vote on which we would like to attend. The list eventually got whittled down (IIRC) to:

  Room 1 Room 2 Room 3 Room 4 (free)
Morning session F# and the Euler project Reusable build scripts OpenRasta  
Afternoon session MVC Testability Secure development Managed Extensibility Framework  

 

If you recognise any of those you’ll realise that there was a definite .Net slant to all of the sessions and given that I am primarily a SQL-y guy I didn’t have that much interest in the morning sessions so I decided to hole myself up in room 4 so that I could do some more investigation of a technology that has become really interesting to me of late – SQL Data Services (SDS). For some time now I have been intending to familiarise myself with Ryan Dunn’s SSDS REST Library which is a .Net library intended to make it easy to interact with your SDS-hosted data. And how!

I am really really impressed with the SDS REST library, as all code libraries should do it just makes the whole process of interacting with SDS incredibly simple and if you are using SDS for data storage I would strongly encourage you to evaluate it. I only had 2 hours in which to build something so decided to simply use SDS to host a list of all the day’s attendees and I wrote a console application to enable someone to add data into it; in the rest of of this blog entry I’ll take you through what I built.

First of all we needed a class for representing an attendee. We want to store the persons name and the morning and afternoon sessions that they attended:

public class OpenSpaceAttendee
{
  public string name { get; set; }
  public string morningSession { get; set; }
  public string afternoonSession { get; set; }
}

Easy so far! Now, before we start interacting with an SDS authority we have to get a reference to it which is what the SsdsContext class in the REST library is for:

image

GetContext() is a simple method I wrote to prompt the user for an authority name, a username and a password hence its not worth showing here. As you can see in the screenshot above our SsdsContext instance contains all the information we need for interacting with our authority.

N.B. SsdsContext only holds a reference though and at this stage the authority might not even exist. SsdsContext does provide a method for creating an authority but does not provide the ability to check whether or not the authority exists; there is nothing in the service that prohibits querying for this information so hopefully Ryan fixes this up in the next release of the SDS REST Library! In my case I created the authority separately (using Omega SdsClient) prior to running the code.

Next step is to create the container that is going to hold all of my data and get a reference to it so that I can add data into it

//Create container if it doesn't already exist and get a reference to it
if (!ctx.ContainerExists("attendees")){
  ctx.CreateContainer("attendees");
}
SsdsContainer container = ctx.OpenContainer("attendees");

Now I need a list of attendees. I wrote a method GetOpenSpaceAttendees() to prompt the user for a list of attendees and return that back to the program:

List<OpenSpaceAttendee> attendees = GetOpenSpaceAttendees();

Now here is where the SSDS REST library really comes into its own. It includes a generic class SsdsEntity<T> which is an SDS-compliant representation of an object that we want to store in an SDS service. It takes care of all the XML serialisation/deserialisation that needs to occur in order to pass the entity into the SDS service and thereafter query it. It has a property called Entity that we can use to interact with the object that has been serialised (in our case an OpenSpaceAttendee). Here I show how to take an OpenSpaceAttendee, wrap it as an SsdsEntity<T> and insert it into our SsdsContainer:

foreach (var attendee in attendees)
{
 
  SsdsEntity<OpenSpaceAttendee> attendeeEntity = new SsdsEntity<OpenSpaceAttendee>
  {
    Entity = attendee,
    Id = Guid.NewGuid().ToString()
  };
  container.Insert(attendeeEntity);

That’s all there is to creating the data. SSDS REST Library also enables us to easily query the data; for example here I show how we can get a list of all the attendees who went to the F# session:

var results = container.Query<OpenSpaceAttendee>(e => e.PropertyBucket["morningSession"] == "F#");

image

Of course, we can query the service directly in a web browser to get the same information:

image

 

In conclusion, the SSDS REST Library makes it incredibly easy to interact with SQL Data Services from a .Net language.

 

The first Open Space Coding day turned out to be a great success and nearly all the credit for that should go to Alan Dean and I’d like to take this opportunity to thank Alan for putting the day together and to Michelle for doing all the logistical adminstrata. Alan has posted photos up on Flickr at: http://www.flickr.com/photos/alan-dean/sets/72157613146486709/

-Jamie

P.S. The full code listing that I worked on is stored up on my SkyDrive if you’re interested:

image

Published 01 February 2009 12:25 by jamie.thomson

Comments

 

Jason Haley said:

February 1, 2009 16:13
 

Dew Drop - February 1, 2009 | Alvin Ashcraft's Morning Dew said:

February 1, 2009 20:59
 

Christopher Steen said:

Link Listing - February 1, 2009

February 2, 2009 05:14
 

Christopher Steen said:

ASP.NET ASP.NET Web Developer Checklist [Via: Scott Kuhl ] WPF Twitter List for Silverlight/WPF Developers...

February 2, 2009 05:16
 

Flynny's Blog said:

The 1st Open Spaces Coding Day organised by Alan Dean and hosted by me in the EMC Conchango offices on

February 2, 2009 10:44
 

DotNetShoutout said:

Thank you for submitting this cool story - Trackback from DotNetShoutout

February 2, 2009 12:10
 

Flynny's Blog said:

The Open Space Coding Days organised by Alan Dean and hosted by EMC Conchango have been such a great

April 9, 2009 14:22
New Comments to this post are disabled

This Blog

Syndication

Powered by Community Server (Personal Edition), by Telligent Systems