Hawaiʻi's Technology Community

So, your jealous about all the new technology stacks that seem to make life so much easier? You no longer have to be.  With the help of a javascript library available at and a very simple implementation of WCF Data Services utilizing the latest Entity Framework, you can open up your data store to the world with ease.


Lets start with the Entity Framework.  It's the 3rd or 4th attempt by the boys at Redmond to provide a serviceable ORM with a Microsoft logo.  This time they've more or less succeeded.  It works seamlessly out of the box with SQL Server and will work equally as well to service Oracle databases with a product from Devart called dotConnect for Oracle.  It offers the standard capability of an ORM and can be tweaked using the T4 templates when needed.

Next in our stack is the WCF Data Services library.  Don't confuse this with the regular WCF Service that is already in heavy use.  This is the successor to ADO .NET Data Services and the facelift has been a success.  The jewel of this library is that it supports OData (Open Data Protocol).  You can read all the details at the linked site but this protocol does data exchange based on the Atom Publishing Protocol.  All data reads and writes are fed into an Atom format making those reads and writes available to any browser (or any other application) that knows what to do with Atom feeds.  Lastly, what WCF Data Services provides is the RESTful interface.  All data requests are available using the PUT, DELETE, POST, and GET verbs supported by HTTP.  Finally, an easy way to expose your data to all the PHP, Rails, Grails, etc hackers out there.

Microsoft also provides a client side to these server side libraries that will allow you to write rich client applications but that's not the point of this post.  The point was to highlight a library at codeplex named datajs.  This little gem takes care of all the gory details of supporting OData.  A sample data request looks like this:    
 function (data) {
      var html = "";
      $.each(data.results, function(l) { 
              html += "
" + l.CategoryName + "
; });
      $(html).appendTo($("#target-element-id"));    }  );
And a simple post of a new record looks like this:
   { requestUri: "/customer-service/Customers",
      method: "POST",
      data: { Name: "customer name", CustomerCategory: 123 } },
    function (insertedItem) {
inserted customer ID: " + insertedItem.ID +
").appendTo($("#target-element-id")); } );

These two snippets can be found in the datajs docs along with lots more sample code.

So set your data free.  Try out WCF Data Services!

Views: 176


You need to be a member of TechHui to add comments!

Join TechHui

Comment by Cameron Souza on April 4, 2012 at 8:54pm

Its great that Microsoft finally landed on a good ORM solution. It was really frustrating watching them introduce and then kill previous attempts. Thanks for the post.


web design, web development, localization

© 2022   Created by Daniel Leuck.   Powered by

Badges  |  Report an Issue  |  Terms of Service