In order to build business application using Silverlight , you may have to work with a lot of data. And that data is usually not resident on the client machine, it is usually distributed amongst many clients and this data is stored and operated on by back-end services.
WCF RIA (Rich Internet Applications) Services is a new part of the .NET 4 and Silverlight 4 frameworks that lets you quickly and easily build N-Tier Silverlight applications by providing framework components, tools, and services that make the application logic on the server available to the RIA Services client without requiring you to manually duplicate the programming logic.
On the server side, WCF RIA Services helps you define your services, domain entities, and supporting logic. On the client side, WCF RIA Services code generates corresponding classes that let you easily call those services, have the same entities available and populated on the client side,
The figure below shows what part of your architecture WCF RIA Services focuses on.
In WCF RIA Service we must be aware of the following key concepts to begin build our
Project Links: A link between a Silverlight client project and a server web application or class library. The server project defines or references the domain services, entities, metadata, and shared code defined on the server side. As a result of the link, appropriate code is generated in the client project at compile time.
WCF Domain Services – This is the core construct of WCF RIA Services. A domain service defines the operations supported on the server side. These operations are exposed automatically via WCF and can be called from the client generated code without needing to know much at all about WCF, yhe WCF Domain Service encapsulate the business logic of a WCF RIA Services application. A domain service exposes a set of related operations in the form of a service layer. When you define a domain service, you specify the data operations that are permitted through this domain service.
Domain Context : This is the client side counterpart to the domain service. It is generated code on the client side that gives you easy access to the functionality that resides on the server side. Internally it contains a WCF proxy that makes the service calls, and it also manages creating the queries that get executed on the server side.
When you create a new Domain Service & build your project, you’ll notice a Domain Context class has been generated for you on the client one for each Domain Service. If you create a Domain Service named MyDomainService, you’ll get a generated Domain Context on your client named MyDomainContext, which inherits from the DomainContext class. It contains query operations to fetch data, collections of the entities you’re exposing through the Domain Service, submit and reject operations, … It provides a lot of functionality to help you with change tracking & interacting with the Domain Service.
the figure below is figuring out how the wcf domain service and domain context interact:
DomainDataSource – This is a data source object that can be used to execute queries and submit changes to the server side. It gets associated with the domain context and makes calls through that domain context on your behalf to query and update entities. It facilitate direct data binding from XAML or can be used behind the scenes as well.
In this article, I covered the basic concepts behind a WCF RIA Services application, we must be aware of these key concepts to start building our WCF Ria services applications.
Stay tuned for the next article , we are panning to build an n-tier application using WCF Ria Service on Silverlight 4.