Yes, that’s right… we now have a component that is a big step toward addressing the request for an MVVM-Friendly DomainDataSource. As of this posting, that feature was the #2 requested item on the RIA Services wish list, and we’ve been pondering its design for a long time. Kyle McClellan has delivered on this and he is posting details to his blog. This feature is completely separate from the DomainDataSource, and it’s built from the ground up with ViewModel usage in mind.
Here are some specific links from Kyle’s blog:
- Collection Binding Options in WCF RIA Services SP1
- Introducing An MVVM-Friendly DomainDataSource: The DomainCollectionView
Here are the links you need to get up and running:
- Install WCF RIA Services SP1 for Silverlight 4
- Install WCF RIA Services SP1 for Silverlight 4 and Visual Studio 2010
- Install the WCF RIA Services December 2010 Toolkit for WCF RIA Services SP1
The RIA Services Essentials project contains sample applications/extensions demonstrating using and extending WCF RIA Services v1.
- Book Club – It was written to demonstrate some aspects of writing a semi-real-worldish application (note that it is still very much a demo app), but more importantly, demonstrating how you can use RIA Services effectively by going beyond the basics.
Here is a list of what the application demonstrates:
- Entity framework data model with one-to-many and many-to-many relationships as well as use of stored procedures
- Local data model augmented/mixed with a web service-based data model (in this case Amazon).
- CRUD and more (queries, insert, update, delete, as well as named update methods, and invoke methods)
- Use of convention and configuration for identifying CRUD operations
- Validation (field level, entity level, operation level, change-set scoped, server-only validation, async validation)
- Custom authentication (i.e. using your DAL/user table, rather than asp.net membership)
- Authorization (including custom authorization rules)
- Using authentication service and your User object in server code
- Usage of DomainServiceFactory
- Exposing reference data
- Presentation model for defining custom (non-DAL) types for use between client and server
- Shared code between client and server for validation rules
- Query limits, and caching
- Using RIA Services with MVVM on the client
- Adding computed properties on Entities on the client along with propagation of change notifications
- "More" style paging (as seen for example on twitter.com)
- Display of pending changes, validation errors
- Reference data used to fill lookup dropdown lists.
A sample Silverlight business application using MEF, MVVM Light, and WCF RIA Services.
A common question in the RIA Services forums is how RIA Services fit into best practices architecture. I was always impressed with the basic forms-over-data capabilities of RIA Services, but I definitely saw the opportunity to better architect my application so the framework concerns didn’t leak into the logic of my application.
When you see demonstrations of technologies most of the time the data samples show single table solutions. When was the last time you’ve developed a single-table system? Thought so.
In RIA Services demonstrations, most of them have been single-table samples as well. So how do you go about retrieving relational data (master/details type) with RIA Services? Here’s an option. Modify the Visual Studio generated MetaData class to add an [include] attribute on top of your chosen EntityCollection<T> and then add a method to our Domain Service class to get the additonal data. e.g.
public EntityCollection<Album> Albums;
public IQueryable<Artist> GetArtistsWithAlbums()
Silverlight 3 includes PagedCollectionView class, which provides UI-level grouping, sorting and paging functionality for any data source that implements the IEnumerable interface. This works as long as all the data that you need to sort, page are already fetched to the client which could be a slow process and can potentially consumed lots of memory on the client-side. A better solution is to provide Server-side sorting & paging.
One way to achieve this is to use .net RIA services’ DomainDataSource and DataPager controls which provides automatic server sorting and paging support. For more details check this out:
However, if you are not using .net RIA services, than you will need to implement ICollectionView to handle sorting and IPagedCollectionView to handle paging yourself –> Silverlight 3 Custom Sorting with Paging Support – Manish Dalal’s blog
By Brad Abrams, this demo requires:
Also check out the author’s Mix09 talk “building business applications with Silverlight 3”.