Friday 13 July 2012

What is WCF RIA Services

 
Following article helps you summarize WCF RIA Services if you know already know what it is.
RIA services are a server-side technology that automatically generates client-side (Silverlight) objects that take care of the communication with the server for you and provide client-side validation.
  The main object inside a RIA service is
A.     A Domain Service, usually aLinqToEntitiesDomainService that is connected to a LinqToEntities model.
B.     When you create a domain service and compile your solution, a client-side representation of your domain service is generated. This client-side representation has the same interface. Suppose you create a server-side domain service Customer Service with a method IQueryable<Customer> GetCustomersByCountry. When you build your solution, a class is generated inside your Silverlight project called CustomerContext that has a method GetCustomersByCountryQuery. You can now use this method on the client as if you were calling it on the server.
C.     Updates, inserts and deletes follow a different pattern. When you create a domain service, you can indicate whether you want to enable editing. The corresponding methods for update/insert/delete are then generated in the server-side domain service.
D.      However, the client-side part doesn't have these methods. What you have on your CustomerContext is a method called SubmitChanges. So how does this work:
E.      For updates, you simply update properties of existing customers (that you retrieved via GetCustomersByCountryQuery).
F.      For inserts, you use CustomerContext.Customers.Add (new Customer (...) {...}).
·         For deletes, you use CustomerContext.Customers.Remove (someCustomer).
·         When you're done editing, you call CustomerContext.SubmitChanges ().
E.      As for validation, you can decorate your server-side objects with validation attributes from the System.ComponentModel.DataAnnotations namespace.
F.      Again, when you build your project, validation code is now automatically generated for the corresponding client-side objects

 Following picture is more explanatory.



No comments:

Post a Comment