WCF - Ria Services


Advertisements

WCF RIA Service is a higher-level framework and a new component of frameworks like .NET 4 and Silverlight 4 that eases the procedure of building a complex business application in Silverlight by offering client-side validation. RIA stands for Rich Internet Applications.

It must be noted here that Silverlight is a framework offered by Microsoft, ideal for rich internet applications and is available for use as a browser plug-in, just like Adobe Flash.

WCF RIA Service is mainly based on the standard version of WCF service. The following figure illustrates a part of the WCF architecture, where WCF RIA services has its focus in general.

Wcf RIA Services 1

Creating a WCF RIA Service is the next step to have a better understanding of the concept. The step-by-step procedure is given below.

Step 1 − Create a new web project of the name SLWCFRiaServices.Web using Silverlight 5 and then add a new item by selecting ADO.NET Entity Data Model to the same.

Wcf RIA Services 2 Wcf RIA Services 3

Step 2 − Now choose model contents from the Entity Data Model Wizard by generating the model from the database.

Wcf RIA Services 4

Step 3 − From the same wizard, choose your data connection and database objects.

Wcf RIA Services 5 Wcf RIA Services 6

Step 4 − Build the solution so that in future, recognizing the data model will not a problem for the domain service you are going to create.

Wcf RIA Services 7

Step 5 − Now create a domain service in the web project by adding a new item and make sure to enable client access.

Wcf RIA Services 8 Wcf RIA Services 9

Step 6 − In the very next step, some classes will be generated and it is essential to build them again.

Wcf RIA Services 10 Wcf RIA Services 11

Step 7 − In this step, DataDomainContext is displayed by the Data Sources Panel.

Wcf RIA Services 12

Step 8 − In this step, the article below the DataDomainContext should be selected and customized.

Wcf RIA Services 13

Step 9 − Attaching the DataGrid Control with the Data Source is the step committed here, along with selection of themes. Here BureauBlue theme has been selected.

Wcf RIA Services 14 Wcf RIA Services 15

Step 10 − The last and the final step comprises of going to the design screen and adding entity in the layout area of the MainPage by simple drag and drop. It is also vital to ensure AutoGenerateColumns = "True" and to run it to view the output.

Wcf RIA Services 16 Wcf RIA Services 17

Prerequisites

There are some prerequisites for experiencing the full potential of WCF RIA services −

  • Visual Studio 2010 / Visual Studio 2012
  • Silverlight Developer Runtime
  • Latest version of RIA Services Toolkit
  • SDK (Software Development Kit)

WCF RIA Domain Service

A domain service comprises of a set of data operations related to business. It is nothing but a WCF service that exposes any WCF RIA Service application’s business logic.

A WCF RIA Domain Service has the hosting class DomainServiceHost internally, which in turn uses the WCF ServiceHost class for hosting the application. To make the domain service accessible for the client project, it should have the EnableClientAccessAttribute attribute. The attribute is applied automatically whenever a new domain service class is added.

The following figure shows the architecture of a WCF RIA Domain Service −

Wcf RIA Services 18

WCF RIA Services – Querying Data

The following figure shows how a query is created on the client side and executed on the server side to return queryable results. DAL stands for Data Access Layer.

Wcf RIA Services 19

WCF RIA Services – Updating Data

The following figure shows how data is updated by executing the CUD (Create Update Delete) operation on the server side. It should be noted here that WCF RIA service is always stateless on the server side.

Wcf RIA Services 20
Advertisements