Blog - Microsoft .NET, ASP.NET, AJAX and more

Ruby OData Update v0.0.7

by Damien White 7/6/2010 8:48:49 PM

OData_logo_MS_small I  just wanted to give an update on the ruby_odata progress.  If you don’t know about ruby_odata or want a refresher, I blogged about it a few weeks ago.  Anyway, I just released a new version of the gem, v0.0.7.  With this new version, you can now perform batch saves (multiple adds, deletes, and updates) and types are being supported.  The library is getting more mature with each revision.  Below is the state of the current gem:

  • <Collection> dynamic methods are available after you instantiate the service.  You can chain query operations like order_by, filter, expand, etc. on to the dynamic methods.
     
  • For querying, $orderby, $top, $skip, $filter, and $expand are supported.  These are represented by the methods order_by, top, skip, filter, and expand (respectively) on the OData::QueryBuilder class (which is returned from the dynamic collection methods), for example: svc.Products.top(10).
     
  • The ability to add entities.  AddTo<Collection> dynamic methods are available after you instantiate the service, allowing you to pass new entities to the methods.
     
  • The ability to update entities though the update_object method on the OData::Service.
     
  • The ability to delete entities though the delete_object method on the OData::Service.
     
  • The ability to batch saves, which allows you to pass multiple objects to be added, updated, or deleted and have them persisted as a batch when you call the save_changes method on the OData::Service.  Note that with batch saves, the changes either complete or fail as a batch.
     
  • Explicit data type support for the following: (Everything outside of this list currently is represented as a string.)
    • Edm.Int16
    • Edm.Int32
    • Edm.Int64
    • Edm.Decimal
    • Edm.DateTime – Note that DateTime is a bit odd.  There’s no time zone data passed from OData services (at least not with WCF Data Services), so it is assumed that the time zone is UTC for all DateTime types.
       
  • Support for Complex Types – From OData.org: “Complex Types are structured types also consisting of a list of properties but with no key, and thus can only exist as a property of a containing entity or as a temporary value.”  You’ll typically see these to logically group properties together.  For example, with the Netflix service, they expose a BoxArt complex type on a Title.  The BoxArt type consists of 3 properties, SmallUrl, MediumUrl, LargeUrl.  This makes accessing these clearer and cleaner, for example movie.BoxArt.MediumUrl.
     
  • Works with Ruby 1.8.7 and Ruby 1.9.1.  It also works with ActiveSupport 3.0.0.beta4.  These were tested on Windows due to using WCF Data Services for the test suite, although, if something Ruby works in Windows there is a good chance everything should be fine on Mac or Linux as well.  I could always change the test URLs to point at a remote machine to do my testing on a Mac, but I wish there was an OData producer like WCF Data Services that would work with ActiveRecord (or similar).
Shout it kick it on DotNetKicks.com Bookmark and Share

Introducing a Ruby OData Client Library

by Damien White 6/12/2010 9:37:28 PM

OData_logo_MS_small Ever since the ADO.NET team started development on Astoria (pre-release), I have loved the concept.  Since its release (it was called ADO.NET Data Services and is now WCF Data Services), I’ve used it a ton (you may remember the example from this post).  Back at MIX10, Microsoft announced a commitment to the Open Data Protocol (OData).  WCF Data Services enables you to create services that use OData to expose and consume data, both with .NET 4 and .NET 3.5 SP1.  OData services are very powerful and there are quite a few live producers such as Netflix and Nerd Dinner.

OData is so powerful because it’s REST based and you can access the services from just about everywhere, including just a simple URL.  For example, using the Netflix OData service to access the best movie ever made by title: http://odata.netflix.com/Catalog/Titles?$filter=Name eq 'Office Space'.  Pretty simple.  Of course accessing things solely based on URLs in code isn’t the best, and hence the reason for my post.

Client Libraries

When using OData, it’s convenient to utilize an SDK to access the services.  For example, in Silverlight you can access OData services using LINQ.  There’s also a fantastic AJAX Library (which I used in a previous post).  There are SDKs for PHP, Objective-C, and many others, but there was one missing that I wanted to use… Ruby.  I am assuming this comes as no surprise given my new found love for Ruby.   More...

Shout it kick it on DotNetKicks.com Bookmark and Share