Quantcast
Channel: Telerik Blogs
Viewing all articles
Browse latest Browse all 5210

Consuming LightSwitch OData services with Microsoft Visual Studio 2012 and Telerik RadDataServiceDataSource

$
0
0

With this post I will show you how to consume Visual Studio 2012 LightSwitch OData services to enable server sorting, filtering, paging, etc. for your custom LightSwitch component:

 

1) Create new LightSwitch application, add some database connection (in my case I’m using Northwind on my SQLEXPRESS instance) and screen:

image

image

image

image

image

 

2) Add new separate Silverlight project (class library) with a custom UserControl to the LightSwitch application, similar to my previous blog post, and select the custom control to be used in our screen:

image

image

 

3) Add service reference to your LightSwitch application (if the application is not yet published, you can check the actual application address from your system tray icon):

image

image

image

 

4) Add Telerik assemblies and declare desired components. In this case I’m using RadGridView, RadDataPager and RadDataServiceDataSource:

image

* Because of the RadDataServiceDataSource you need to add reference to System.Data.Services.Client.dll however if you try to compile the application you will get errors due to duplicate types. To resolve these errors you can remove all references to the Silverlight class library project added automatically after the service reference

image

image

** If you do not have also latest updates, like yours truly, you will need also to change the constructor for your service context (remove the second parameter):
image

 

5) Setup the service URI and components and run the application to check the result:

image

image

image

* For every filter, sort, page, etc. you will get separate call to your database server with all needed info to apply requested operations at once:

image

image

 

Enjoy!

Download


Viewing all articles
Browse latest Browse all 5210

Trending Articles