Wednesday, December 30, 2009

WCF RIA Services – Domain Service Lifecycle

Frederik Normén posted a really good article on the message flow through a Domain Service. Domain Services differ from standard WCF service in that you normally don’t call their operations directly:

For each object you want to expose and edit on your application you expose at least one query method (something that returns an IQueryable of the object) and the CUD methods for that entity.

At the client side that object is exposed in a EntitySet (a set of the entity) where you can add, remove or change entities. Those actions (ChangeSetEntry) will be recorded and collected into a ChangeSet. Once you are finished with the current business operation you call SubmitChanges(). This call will in practice create a wcf request to a service prepared to accept the ChangeSet as a request message. The article explains how the service handles that call. It can be found here.