Monday, December 9

OData service in Visual studio LightSwitch

Introduction: Exposing data through the Web/Network is a very common business need. It is done by services that can be consumed by several clients.There are many APIs to expose and consume data. The OData (Open Data Protocol) provides a standardized way to expose, structure, query and update data, based on REST approach. OData also provides metadata about data, allowing computer to know more about the type system, relationships and structure of data. It is built upon web technologies such as HTTP, Atom publishing Protocol AND JSON and provides access to information from a variety of applications, services and stores.

Currently there are lot of public OData services that can be used. Few of them are:



In this demo, I'll consume data from http://services.odata.org/OData/OData.svc/  and display the data from advertisement entity.

 Steps:

  1. Open Visual Studio 2012.
  1. Go to "File" => "New" => "Project..."
  1. Select "LightSwitch" in installed templates.
  1. Select "LightSwitch Application (Visual C#)".
  1. Enter the Name and choose the location.
  1. Click "OK".



Now click on "Attach to external Data Source" and select ODataService and click the "Next" button.







Now enter the connection information and specify the OData service endpoint and click the "Next" button.



Select  entities and click "Finish". I selected Advertisement.

The designer will look like this

Now add a screen and provide service name.


Run the application to see the list of advertisements.


No comments:

Post a Comment