WCF RIA Services Part 4 – MVVM articles is live

Part 4 of my series of WCF RIA Services is now live on The Silverlight Show here.

In this episode, I focus on using RIA Services in an MVVM world. That includes not using the DomainDataSource anymore and encapsulating the domain context in your view model and making the calls through it from there. You can expose the entity collections from the domain context directly as properties on the view model because they are a collection that raises CollectionChanged events when the underlying data changes, and the entities implement INotifyPropertyChanged so they participate nicely with data binding. They also implement INotifyDataErrorInfo and integrate nicely with the Silverlight data binding mechanisms.

The only downside to that approach is that you cannot easily mock out the domain context dependency, so it makes it hard to unit test your view model, which is one of the motivations for using the view model pattern in the first place. At the end of the article I point to a recommended solution from the RIA Services team – specifically to mock out the DomainClient that sits on the other side of the domain context and makes the actual service calls. That is not super easy, but it is at least a solution. I’m going to expand my sample to include that approach in Part 8 of the series.

Check it out and let me know what you think.