8
votes

Does anyone know if there an open-source .NET wrapper that can reliably parse the OData protocol Uri?

I'm not looking for pointers to WCF Data Services... I'm creating a WCF-based data querying service that (for complicated reasons) cannot be a real Atom/OData service, but I really like the expressiveness of the OData Uri for identifying a datasource and query parameters. Plus we may expose an OData endpoint some time in the future.

I've looked (cursorally) through the WCF Data Service API and there does not seem to be a neatly wrapped-up ODataUri class that exposes service host, resource path and query parameters. I can write one, but before I do I'd rather see if someone has done it already.

1
Sure, read this blog post as a starter: tirania.org/blog/archive/2010/Mar-22.htmluser333306
So, unless I'm missing something, this articles discusses the need for MS to open-source the data services server code (the stuff I need!). I agree with the sentiment, but it doesn't help me because MS hasn't OS'd the server code and so I can't get at their uri parser (I guess I could try reflector, but that's likely to be a lot of trouble).Simon Gillbee
It is: odata.codeplex.comuser333306
Thanks. I'll look at the client code. it was my impression that a uri parser was going to be a server-side component, not a client side component, but I could be wrong.Simon Gillbee
I too would be interested in this, did you manage to find/create a wrapper? Are you able to share your findings?Alex

1 Answers

6
votes

I know you said you looked at the API, but have you looked at the actual code. The .Net Client Library has been opened sourced, http://odata.codeplex.com/ so if you can't find one out there, you can use their code as a starting point (and hopefully contribute it back to the community).

Essentially, what you need is a LINQ to OData Uri provider. If I remember correctly, one of the nick-names for Astoria was LINQ to REST. What you have to do is on the client side, convert a LINQ expression tree to the OData URI format, and on the server, convert the URI back to a LINQ Expression tree. Creating custom LINQ providers isn't the easiest thing to do, but Matt Warren has a great (long) series on building IQueryable Providers http://blogs.msdn.com/b/mattwar/archive/2008/11/18/linq-links.aspx