Building Applications and Services Using Open Data Protocol

Version: 1.0.0

Description

Throughout this hands-on lab you will understand the ecosystem that provides Open Data Protocol (OData), how to create OData feeds over SQL Server and how to import OData feeds for Silverlight applications.

Overview

The Open Data Protocol (OData) is a web protocol for querying and updating data. Its specification is available under Microsoft's Open Specification Promise (OSP), therefore third parties, including open source projects, can build Open Data Protocol clients and services.

OData is defined as a set of open extensions/conventions to AtomPub. It adds the following features to AtomPub.

  • A convention for representing structured data
  • A resource addressing scheme and URL syntax
  • A set of common query options (filter, sort, etc.)
  • Schema describing resource structure, links and metadata
  • Payload formats and semantics for batch and “unit of work” requests
  • Alternate representations of resource content (JSON)

In this lab, you will learn about the Open Data Protocol, the ecosystem where it works, and why developers should write applications and services using the Open Data Protocol as their Data Access protocol. You will also learn how to create simple applications in various technologies that manage the OData feeds.

Objectives

In this Hands-On Lab, you will learn how to:

  • Use Open Data Protocol in different environments
  • Create an OData feed over SQL Server 2008

Prerequisites

The following is required to complete this hands-on lab:

  • Microsoft Visual Studio 2010
  • Microsoft .NET Framework 4
  • SQL Server 2008 Express Edition (or above)
  • Silverlight 4 Tools for Microsoft Visual Studio 2010

Setup

All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps:

Note:
To perform the setup steps you need to run the scripts in a command window with administrator privileges.

  1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, browse to Source\Setup folder of this lab, and double-click the Dependencies.dep file. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.
    Note:
    The Configuration Wizard is used for checking dependencies and setting up the environment. If the Configuration Wizard is not installed on your machine, you must install it running the DependencyChecker.msi file located on the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the Training Kit is installed under C:\VS2010TrainingKit).

    For convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. The Dependencies.dep file launches the Visual Studio installer file that installs the code snippets.

Using the Code Snippets

With code snippets, you have all the code you need at your fingertips. The lab document will tell you exactly when you can use them. For example,

To add this code snippet in Visual Studio, you simply place the cursor where you would like the code to be inserted, start typing the snippet name (without spaces or hyphens), in this case LabNameEx01RunmethodCS, watch as Intellisense picks up the snippet name, and then hit the TAB key twice once the snippet you want is selected. The code will be inserted at the cursor location.

Figure 1

Hit TAB to select the highlighted snippet.

Figure 2

Hit TAB again and the snippet will expand

To insert a code snippet using the mouse rather than the keyboard, right-click where you want the code snippet to be inserted, select Insert Snippet followed by My Code Snippets and then pick the relevant snippet from the list.

To learn more about Visual Studio IntelliSense Code Snippets, including how to create your own, please see Creating and Using IntelliSense Code Snippets.

Exercises

This Hands-On Lab comprises the following exercises:

  1. Introduction to Open Data Protocol
  2. Creating an OData Feed over SQL Server
  3. Building a Silverlight Client with OData Feeds

Estimated time to complete this lab: 60 minutes.

Starting Materials

This Hands-On Lab includes the following starting materials.

  • Visual Studio solutions. The lab provides the following Visual Studio solutions that you can use as starting point for the exercises.
    • Source\Ex2\Begin\[C#|VB]\OpenDataServices.sln
    • Source\Ex3\Begin\[C#|VB]\OpenDataServices.sln
    Note:
    Inside each exercise folder, you will find an end folder containing a solution with the completed lab exercise.