Reputation: 3982
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.
Upvotes: 8
Views: 2163
Reputation: 221
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
Upvotes: 6