Thursday, August 5, 2010

WCF RIA SERVICES v1.0 - Extra Cool Samples !

Today I’ll write about very interesting scenarios with WCF RIA Services. Read this post!

I. NHibernate

You can quite easily use NHibernate as your DAL. Look at the latest NHibernate Sample from WCF RIA Services Code Gallery with related entities! I have made a simpler example without associations (look below).

01_NHibernate_01 01_NHibernate_02 01_NHibernate_0301_NHibernate_0401_NHibernate_05

II. MVVM

Nikhil Kothari at MIX 10’ has shown how to use WCF RIA Services with MVVM pattern (domain context as a member of view model). Deepesh Mohnani at TechEd 2010 has presented a great WCF RIA Services application with MVVM (for lazy developers: view model inherited from Entity). 

III. Lookups (ComboBoxDataSource)

Kyle McClellan from WCF RIA Services team has added to code gallery a cool example with an extension to support lookups - ComboBoxDataSource. He has implemented cascading ComboBoxes scenario (lookup data sources with parameters like DomainDataSource filters). You can also see how to use lookups for Entity associations. Read about details of the solution here and here.

I have built a simpler example with one ComboBox for Entity association (look below).

02_Lookup_01 02_Lookup_03 02_Lookup_04

IV. T4

Early versions of WCF RIA Services Contrib had contained T4 templates for generating domain services and metadata classes (replacement WCF RIA Services wizard). Now T4 templates have been made obsolete - WCF RIA Services V2 itself is supposed to start using T4 templates

V. Fluent metadata !

The standard approach of defining WCF RIA Services entity metadata is based on attributes. But some developers don't like attributes and ask for a fluent interface instead. Nikhil Kothari has created Fluent API for .NET RIA Services Metadata for July 09’ version. LINQ expressions are mapped to WCF RIA Services. attributes. You can also define your own custom rules (mapped as standard CustomValidation attributte). Nikhil will add these extensions to RIA Services Essentials at codeplex.

Some people and I have migrated these extensions to work with WCF RIA Services V1. I have made example application with fluent metadata (look below).

03_FluentMetadata_02 03_FluentMetadata_03 03_FluentMetadata_01

VI. Offline

Nikhil Kothari at TechEd 09’ South Africa has presented an offline synchronization example (he’ll plan to public update for it).

WCF RIA Services DomainContext is good for offline scenario. WCF RIA Services Contrib contains an extension to serialize it to Isolated Storage and deserialize from.   

I have tried to migrate Nikhil Kothari’s solution to work with WCF RIA services V1 and it … works! I have built simple application using this mechanism (look below).

04_Offline_0104_Offline_0204_Offline_0304_Offline_0504_Offline_06

You can download my examples (NHibernate, Lookup, Fluent metadata, Offline) here:

No comments: