Tuesday, May 18, 2010

Building SilverLight Application using WCF RIA Services.

 

WCF RIA Services.

In Silverlight project you can turn on WCF RIA Services Link. This WCF RIA Services link connects Silverlight client Application and Web Project.

image

WCR RIA Service simplify the N-tier development and it allow to share Data model, Validation Rules and other Data annotations across tiers. what ever methods or Entities which are add in Server Side its replicates to client side application this makes easy access to server side entities. We Add Domain Service class to expose WCF RIA Service on Server side. When you compile the project it automatically creates corresponding Domain Context class in client application this Class helps to tracking changes and CURD operations of Entities.

Here I am going to build Simple Application which uses WCF RIA Services.

1) Fire up VS.NET 2010 and Create SilverLight Business Application.

image

  This project Creates two application one is Silverlight client project and web project as shown below. This to projects connected or Linked using WCF RIA Services. 

image

image

Now I am going to add  EF model from one of the sample Database which you can download from CodePlex.

image

      Now follow the Wizard.

      Next we are going to select Generate From Database options. Here we are going to generate our model from Existing Database. 

image

   Select Database which you wanted to use here I am going to use Chinook Sample DB.

image

     Here we need to select the Tables which you wanted to add to our EF Model. Here I am going to select Customer and Employee Tables.

image

Now we have created our model. At this point we need to compile our project so that Silverlight application will know the new changes to our solutions. Now we need to Add Domain Service Class.

  image

  Please make sure that next step you check the checkboxes as shown below. Here I am enabling Editing options for both Customer and Employee entities.

image

Now we can start  building UI to display Customer records on client side. Now select Data Source and click and select DataGrid then Drag and Drop Customer To UI Design Surface.

image 

At this point VS.NET created Domain Data Source control. as shown below.

image[71]
Now runt the application you will see customer Details displayed in Data Grid as shown below.

image

Nandri(Thanks)

SreenivasaRagavan.

No comments: