Skip to content

Getting started with Simple.OData.Client

object edited this page Feb 12, 2013 · 37 revisions

The easiest way to start using Simple.OData.Client is to install it’s Nuget package. In Visual Studio open Package Manager console and type the following:

Install-Package Simple.OData.Client

You will see output similar to this:

Successfully installed 'Simple.OData.Client 0.10.0'.
Successfully added 'Simple.OData.Client 0.10.0' to SimpleODataTest.

In the source file where you will be using OData provider import namespaces:

using Simple.OData.Client;

Now you can access data from the OData server using either basic or fluent API.

var client = new ODataClient("http://packages.nuget.org/v1/FeedService.svc/");

Create an instance of ODataClient by passing an OData service URL:

var packages = client.FindEntries("Packages?$filter=Title eq 'Simple.OData.Client'");
foreach (var package in packages)
{
    Console.WriteLine(package["Title"]);
}

Create an instance of ODataClient by passing an OData service URL:

var x = ODataFilter.Expression;
var packages = client
    .For("Packages)
    .Filter(x.Title == "Simple.OData.Client")
    .FindEntries();
foreach (var package in packages)
{
    Console.WriteLine(package["Title"]);
}

See also:
Simple.OData.Client basic API
Simple.OData.Client fluent API
Retrieving data
Modifying data