Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a dynamic OData client in C#? [closed]

Microsoft provides a WCF Data Services Client Library to implement OData clients in C#. This library works on the principle of creating a typed reference to the OData service.

What would be a good approach to implement an OData client in C# without having to previously generate a typed service interface? In other words, what would be a good way to implement an OData client in C# that could work with several different OData services, given the base URL and entity names as strings?

Such client would use dynamic C# objects or dictionaries to represent the entities, instead of typed entity objects.

Which existing libraries or projects could be leveraged to implement this?

One application of this technique would be to develop a generic functional test suite helper library that could be used to implement tests of OData services.

like image 606
Fernando Correia Avatar asked Jan 13 '12 11:01

Fernando Correia


2 Answers

The pointer to odata-sdk above is definitely a good start. For one the OData Explorer which is also listed on that site is almost exactly what you're looking for. It's a general OData service "browser".

Another approach (maybe even better) would be to use Microsoft.Data.OData.dll. It's part of the latest CTP of WCF Data Services (http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx). It's a low-level reader and writer for OData. It doesn't solve the URL processing, but reading and writing the payloads works great. There's a sample of a usage here: http://blogs.msdn.com/b/astoriateam/archive/2011/10/14/introducing-the-odata-library.aspx

like image 189
Vitek Karas MSFT Avatar answered Oct 18 '22 21:10

Vitek Karas MSFT


you need nothing more than a URL/ String Parser for this , for more drill down approach you may also like to look at some options here:

http://www.odata.org/developers/odata-sdk

like image 24
Rizwan Avatar answered Oct 18 '22 21:10

Rizwan