Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight 4 WCF RIA Services and MVVM is not as simple

[Disclaimer: I'm ASP.NET MVC Developer]

Hi,

I'm looking for some best practices with implementing MVVM pattern with WCF RIA in Silverlight 4.

I'm not looking to use MEF of IoC for locating my ViewModels. What I would like to know is how to apply MVVM pattern with Silverlight 4 and WCF RIA.

I don't want to use other stuff like Prism or MVVM Light toolkit. I found many examples on Internet showing how it is wonderful to drag and drop a datasource on the view and the job is done (it reminds me about my first VB6 developments).

I tried to implement MVVM with WCF RIA and it's not strightforward at all. If I understand, the MVVM should contain all the logic in order to unit test it in isolation but when it comes to combine it with WCF RIA it's another story. I have the following questions.

  1. Can I use a generated metadata as model ? It would be easier to use it that if I write all from the scratch.

  2. As I saw the only way I could get data is through DomainContext or through direct binding in the view (local ressource). I don't want the direct binding in the view, not testable at all. On the other hand I can't use DomainContext, it doesn't expose any single entity !!! All I have is the EntitySet that I can bind to datagrid. How do I bind a single Entity to the DataForm from the ViewModel ?

  3. How do I udpate the model to the database ?

  4. How do I navigate from one Entity to a collection of it's items. For example if I have a Company Entity I would like to show a DataForm to update an entity informations and a datagrid to show companies adresses. When saving a form, I would like to save an information to Company and an information to adress about which adress was selected as active.

Please help me understand how to do it well. Or maybe I should drop the WCF RIA and to do it with WCF from scratch ?

What do you think ?

like image 957
Tomasz Jaskuλa Avatar asked Apr 28 '10 22:04

Tomasz Jaskuλa


1 Answers

You might be interested in this session. It explains how to use the MVVM pattern with RIA WCF Services.

like image 56
Larry Grass Avatar answered Sep 27 '22 19:09

Larry Grass