Microsoft simplifies the integration of n-tier application development in Rich Internet Application by introducing WCF RIA Services. WCF RIA (also called Domain services) is traditional n-tires application pattern, used with RIA such as Silverlight and it can be used as middle tier.
To know more about WCF RIA Service please refer to the following link.
http://msdn.microsoft.com/en-us/library/ee707344%28v=vs.91%29.aspx
Steps for creating such an application are below.
- Create New Silverlight Application
New project >> Select Silverlight Application.
- Check "Enable WCF RIA Services" check box
- Create Entity Data model.
- Select tables, views and stored procedure from given list to add it to the entity data model.
- Create Domain Service.
Before adding a new domain service, compile the web project.
- Map or enable entity(s) with domain service. In the Entities list you get all tables (also called entities) available in the entity model.
- Now build both projects; Silverlight as well as web. After compiling you will have automatically generated code in the Silverlight project which is responsible for communication between Silverlight and the Domain service.
- The Domain service has many built-in methods for selecting, inserting, updating and deleting the entity(s). You may also add new methods as per your requirement.
In the attached Silverlight project we a create a custom method to get the customer from its id.
public CustomerMaster GetCustomerFromId(int customerId)
{
return this.ObjectContext.CustomerMasters.Where(d => d.CustomerId == customerId).FirstOrDefault();
}
After completion of the web project, you may access this method in Silverlight project.