Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a .NET class wrapper for the OData protocol Uri

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.

like image 457
Simon Gillbee Avatar asked Sep 01 '10 20:09

Simon Gillbee


People also ask

What is OData wrapper?

OData is a protocol to access data created by Microsoft. It provides CRUD operations and is similar to JDBC or ODBC but not limited to databases. OData uses protocols ATOM and JSON and the requests use a REST model. For this reason, OData is an implementation of the RESTful API that describes the data and their model.

What is OData URI?

The Open Data Protocol (OData) enables the creation of REST-based data services, which allow resources, identified using Uniform Resource Identifiers (URIs) and defined in a data model, to be published and edited by Web clients using simple HTTP messages.

How does OData query work?

The OData Protocol is an application-level protocol for interacting with data via RESTful interfaces. It supports the description of data models, editing and querying of data according to those models.

Is OData old?

In computing, Open Data Protocol (OData) is an open protocol that allows the creation and consumption of queryable and interoperable REST APIs in a simple and standard way. Microsoft initiated OData in 2007. Versions 1.0, 2.0, and 3.0 are released under the Microsoft Open Specification Promise.


1 Answers

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

like image 87
Don Demsak Avatar answered Oct 06 '22 01:10

Don Demsak