Overview of oData Protocol for Windows Phone | CodeGuru

Overview of oData Protocol for Windows Phone

Introduction Windows Phone application developers frequently need to access data to present in their applications. Of the variety of facilities available for data services, Microsoft touts oData as solution, which is based on entity and relationship model that allows access to data in REST style (REST stands for representative transfer). What is oData? The documentation […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 24, 2011
3 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Introduction

Windows Phone
application developers frequently need to access data to present in their
applications. Of the variety of facilities available for data services,
Microsoft touts oData as solution, which
is based on entity and relationship model that allows access to data in REST
style (REST stands for representative transfer).

What is oData?

The documentation for Open Data Protocol defines it as a Web
protocol for querying and updating data and builds upon Web technologies to
provide information from a variety of applications, services and stores.

Odata provides a client library for the windows phone
platform that can generate http requests to the odata data service provider. The
library is available
for download from odata’s codeplex page
. The client library transforms the
response feed into objects, which can be used by the application.

Where to Get the Client Library?

To get the client library, download
the latest version
. When you extract the contents, you will find the
following files:

DataSvcUtil.exe – tool to generate data classes that
represent the data model of an OData service. This tool has a few command-line
options which we will discuss later.

Readme.txt – describes the contents of the client
library.

System.Data.Services.Client.dll and System.Data.Services.Design.dll
– client libraries we will discuss in another article.

If you open up System.Data.Services.Client.dll inside Visual Studio‘s
Object browser, you will notice it contains the following classes:

Open up System.Data.Services.Client.dllB in Visual Studio
Figure 1: Open up System.Data.Services.Client.dll in Visual Studio

The DataServiceContext class helps to abstract the
implementation against specific data services and also helps maintain change in
state of entities on the client, which helps to support change tracking and
identity management.

To start with, when using an OData data service provider, we
need to generate data classes for consumption in our application.

We use the datasvcutil.exe for this purpose.

For example, if you were developing a NetFlix application,
you can use the datasvcutil to generate the data classes.

datasvcutil /uri:http://odata.netflix.com/v1/Catalog/ /out:.\Netflix.cs /DataServiceCollection

Let us look all the arguments supported by datasvcutil.exe.

/uri: The URI hosting the OData Service.

/out : The name of the data class file you want to
generate. This file will represent the data objects.

/DataServiceCollection: This ensures that
DataServiceCollection classes are generated for each collection in the model.
This facilitates easy binding to UI elements.

/in: The path of the file to read the conceptual
model from.

/language: You have an option to generate data
classes in either VB or C#. By default, the language is C#.

/help: displays the help text.

DataServiceCollection is a dynamic data collection that
provides notifications when collection gets modified.

Advertisement

Using Data Services

All operations against data services in the Windows Phone
platform are asynchronous. Also, these operations are performed using Begin/End
method pairs. The Begin method lets you register a delegate, which can be
called by the operating system. This delegate will then call the End method
when invoked.

How oData Queries Work

When an application makes a URI based query against an oData
service, the BeginExecute method is called. The client library then creates an
HHTP GET request message, which is then fired. When an EndExecute method is
called, the client library parses the response message to convert it to data
service class instances.

Since OData limits data that a query can return,
you can use LoadNextPartialSetAsync
to load the next set of data.

Summary

This article presented an overview of the OData Protocol. In
a subsequent article we will learn how to develop a Windows Phone application,
which consumes an oData service.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.