WCF RIA services and WCF data services RRS feed

  • Question


    What is the difference between WCF data services and WCF RIA services w.r.to Silverlight client?  How to choose this technology for an application? 


    Monday, July 19, 2010 4:10 AM


  • WCF Data Services is a native OData service and client. It is designed around a communication method where the structure of entities and their relationships is described within the communication itself. This means that it is easy from the client side to query anonymous types but it also means that all relationships have to be defined by queries to be used from the client side correctly. This means that if you have EntityA and EntityB and you load them to the client in two separate queries there will be no associations between them even though the underlying model defined them. The association propeties will be there, they just will not be linked up. It also means that the communications themselves can be extemely "fat" as if you do query EntityA and EntityB together each EntityA will contain every EntityB that is linked. In a one to many relationship, that means that if you have 20 EntityAs linked to the same EntityB then the same EntityB will be in the file 20 times.

    WCF RIA Services is designed for LOB (Line of Business) applications and is less specialized in what protocol it supports. RIA Services is designed around having the structure and relationships of entities described at compile time. Because of this, RIA Services doesn't have support for querying anonymous types. Associations between objects are created using foreign keys, like a database does it. This means that if you separately query EntityA and EntityB, based on the foreign keys the client side will automatically populate the association properties. It also means that if you do query EntityA and EntityB together as I described in the Data Services section you will get 20 EntityAs in your communication and one EntityB.

    All of the other differences between the two revolve around the above basic design differences. Data Services has changes tracked by the context and RIA Services entities are self tracking. Data Services CUD methods make changes to the underlying model automatically and then let the user code know what changed. RIA Services CUD methods leave it up to user code to actually make the changes to the model. Etc.

    Generally, if you are in a heavily query based application where you are trying to create reports and graphs and stuff like that Data Services is better due to its more flexible querying abilities. If you are trying to create an application that actually creates, updates, and deletes stuff then RIA Services is the better choice due to its strongly typed object model, associations that automatically link up entities to each other regardless of load method or load order, and more flexible server side CUD methods.

    Monday, July 19, 2010 8:23 AM