.netodatawcf-data-servicesportable-class-library

Can I use OData client code inside a Portable Class Library?


I'm trying to build a portable class library targeting .NET, Silverlight, Windows RT and Windows Phone that acts as an OData client. I'm using Visual Studio 2012.

When I created the service reference to my OData server side, I got the following error message:

Unable to add a service reference to the specified OData feed because WCF Data Services is not installed for this target framework. To install a supported version of WCF Data Services, see http://go.microsoft.com/fwlink/?LinkId=253653.

When I go to the URL listed in the error message, I can choose between a library for Windows RT and one for Windows Phone, so this does not seem to work for a portable class library.

Is there any secret workaround to this, or do I have to code my own Odata client with bare HTTP requests?

Also, if I do have to use bare HTTP Requests, is there at least some kind of API I can build on for JSON or XML serialization / deserialization that works inside a portable class library?


Solution

  • Actually I have a portable class library for OData (Simple.OData.Client) but didn't make a NuGet package for it yet. It's a part of Simple.Data OData adapter.

    I am using Simple.OData.Client PCL in the app that I plan to port to various platform including iOS and Android (using Xamarin). If you are interested to give it a try I propose one of two alternatives:

    a) Clone the Simple.Data.OData repo (https://github.com/simplefx/Simple.OData), switch to "winrt" branch, build it, there you have Simple.OData.Client that is a PCL supporting most of the platforms. Wiki currently describes Simple.Data adapter syntax, so you need to check Simple.OData.Client tests (https://github.com/simplefx/Simple.OData/tree/master/Simple.OData.Client.Tests) to understand the syntax. It has supports two syntax flavors: when you format filter string yourself and when you use its fluent API. Both of them are very straightforward to use.

    b) I can speed up work on a NuGet package for a PCL (currently uploaded NuGet package only supports NET4), but it will take longer time.

    Let me know if you are interested.