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;

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

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

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

Example of basic API syntax:


1
2
3

afsd
var packages = client.FindEntries(“Packages?$filter=Title eq ‘Simple.OData.Client’”);
foreach (var package in packages)
{
Console.WriteLine(package[“Title”]);
}

Example of fluent API syntax:


1
2
3

dafdaf
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”]);
}

efefwefw

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

ewfwef


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