5 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 1
4 star 4
3 star 0
2 star 0
1 star 0
Compatible with
  • iOS
  • Windows
  • Android

Simple OData Client 4.0

Vagif Abilov

Cross-platform library to communicate with OData services.

Simple.OData.Client

Simple.OData.Client is a multiplatform OData client library supporting .NET 4.x, Silverlight, Windows Phone, iOS and Android platforms. The library supports both typed and dynamic syntax (as long as dynamic is supported on the selected platform), doesn't require generation of context or entity classes and fits RESTful nature of OData services.

Simple.OData.Client uses non-blocking asynchronous model and internally depends on Microsoft HttpClient library.

Xamarin Store component and NuGet package

Simple.OData.Client is packaged as both Xamarin Store component and a NuGet package (available from NuGet.org). Both library sources correspond to the same library. If the application is developed for several platforms, it can be more convenient to use Simple.OData.Client NuGet package that is optimized for binary reuse and targets multiple platforms with the same assembly. If the application targets a single platorm, choice of either Xamarin Store component or NuGet package is just a matter of a developer's preference. In any case it's a NuGet package that is installed, Xamarin Store component is just a wrapper around the NuGet package.

Simple.OData.Client NuGet package supports all OData protocols (versions 1-4), but the unified support comes at the cost of the package footprint. If you know the version of the OData service you are going to use, you can install from nuget.org the version that targets the specific OData protocol (Simple.OData.V3.Client or Simple.OData.V4.Client). In that case you shouldn't be using a Xamarin Store component but install the chosen package directly from nuget.org.

Quick Usage

Simple.OData.Client comes with typed and dynamic API. Typed API is supported on all platforms, support for dynamic API is experimental on iOS and available on other platforms.

Example of a typed API syntax:

var client = new ODataClient("https://nuget.org/api/v1");

var packages = client
    .For<Packages>()
    .Filter(x => x.Title == "Simple.OData.Client")
    .FindEntries();

foreach (var package in packages)
{
    Console.WriteLine(package.Title);
}

Example of a dynamic API syntax:

var client = new ODataClient("https://nuget.org/api/v1");
var x = ODataDynamic.Expression;

var packages = client
    .For(x.Packages)
    .Filter(x.Title == "Simple.OData.Client")
    .FindEntries();

foreach (var package in packages)
{
    Console.WriteLine(package.Title);
}

See "Getting Started" document for an example of using Simple.OData.Client to build an application NuGetFinder that searches NuGet OData feed.

Other Resources

Release Notes

Version 4.0 changes

  • Revised OData parser and formatter to use Microsoft ODataLib
  • Added support for JSON payload
  • Added support for OData V4
  • Added support for iOS/Mac Unified API
  • Various bug fixes
Write a Review

6 reviews

Wojciech Wieronski

This looks like an amazing library. I'm trying to use it in a PCL library that targets PCL 4.5 Profile111. When I try to execute a test in my test project consuming MY PCL Library, I get a System.Aggregate Exception stating "System.Net.Http" can't be found. I'm using Xamarin Studio on a Mac OS X 10.9.5 with the latest version of Xamarin. Any ideas?

Posted on: April 23, 2015 / Version: 4.0
Georgios Papageorgiou

Hello,

Just wish to ask you if Simple.OData.Client (version 4.0) is compatible with Android 5.0+. I already have developed an application that is based on your library for exchanging data with an erp system (Android version 4.*) but I realized that my application fails when it tries to fetch data from the odata source. Although the client object is instantiated, when the following line is executed,

var bu = client.For("BusinessUnit").FindEntriesAsync(); I get an error message from the system. The odata service is built using Lightswitch and my application works properly using Android version 4.*.

Thanks

Posted on: March 31, 2015 / Version: 4.0
Vagif Abilov

Hi Navaneeth,

Simple.OData.Client doesn't generate proxy classes but you should be able to easily add classes for entities you plan to use by navigating to the OData feed and inspecting its metadata. Use URL $metadata to obtain metadata description. If you have Visual Studio you can create a proxy by creating a project and adding service reference to it. Then you can use the generated classes.

Hi Safdar,

In case Simple.OData.Client is referenced from its Xamarin component, the application should also reference HttpClient DLLs (System.Net.Http, System.Net.Http.Primitives, System.Net.Http.Extensions). Did you check that you have references to these DLLs?

Hi Glen,

I know there were some issues with OData services exposed using LightSwitch, are you using it by chance? Anyway, there is a new version of Simple.OData.Client that is currently in beta and supposed to fix this problem. It's not yet released as Xamarin component but available as a NuGet package pre-release. If you have a chance to get it from NuGet (version 4.0.0-rc5 or later) then I hope it will work for you, otherwise give me a ping.

Posted on: October 28, 2014 / Version: 3.0
Glen Poon rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Retrieving data and insert data is ok, but when I update or delete ,it throws AggregateException,innerException is "Method Not Allowed",can you give me some advice?follow is the code :

var client = new ODataClient("http://localhost:50347/v1/StorerDataService.svc/"); var pickRuleset = client.For(). Filter(x => x.DESCS.Length == 6) .DeleteEntriesAsync(); Console.WriteLine(pickRuleset.Result);

Posted on: October 28, 2014 / Version: 3.2
Safdar Ali rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Well i have figured out the issue and iam successfully created Asp.Net OData WebApi and using this Library i did most the operations Like Get record , Insert record but i am facing problem in updating kindly guide me what iam missing.

Public async void Update() { var r=await odataClient .For() .Key(10) .UpdateEntryAsync(); }

Posted on: October 5, 2014 / Version: 3.2
navaneeth ramamoorthy

How to create / add proxy in Xamarin.IOS for WCF Data Service which uses OData Protocol V3

Posted on: August 5, 2014 / Version: 3.0