How can I take advantage of RIA form generation and validation in an application that uses Entity objects over WCF?

This isn't a specific coding question, but rather I'm looking for some advice on how to approach a problem of mine. I have a Silverlight 5 application that uses WCF to do most of its operations - I like the control it gives me compared to RIA. A lot of these WCF methods take Entity Framework objects as arguments, with extra logic and authorization handled on the server side. This works fairly well and I have a nice little framework that lets me pass objects back and fourth, while knowing that the server will only let certain things be changed depending on the user's permissions.

There are a few things about RIA I like though. I use it to populate datagrids because of its easily generated filters, ordering, etc. I've used RIA more heavily for projects in the past and I mostly like its form generation and validation metadata abilities. I like that, with a class, it will easily make me a form with all the textboxes, combodoxes, checkboxes, labels, etc, as well as with two way binding and validate on error set up for each of these. Tying in with validation, because I'm using Entity Framework objects, I can't just stick DataAnnotations on the ORM generated classes, so the autogenerated metadata classes of RIA are very useful in that regard.

The issue seems to be that these objects are incompatible. I can't use RIA generated classes with my methods that are expecting Entity Framework objects. I can't use RIA to generate the forms and then bind them to my regular entity objects because then there's no automatic validation. Does anyone have any ideas on how I can marry these two? I'm open to thoughts/suggestions.

Answers


The form generation and validation magic is not tied to RIA Service client's EntityObject base class.

If you annotate your WCF client's proxy classes with Validation Attributes, you can get more or less the same result.

If you implement IEditableObject, then the datagrid will restore modified data when you hit ESC.

Through careful use of .shared.cs files, and linked source files, you can have most of the server side and client side code being shared.

To achieve even more flexibility, you will need to start crafting your own T4 templates.


Need Your Help

VB.NET tooltips just stopped working, VS2010, Windows 7

vb.net visual-studio-2010 tooltip

I've got a complex form where some components are hidden until they are needed. I'd only got a few tooltips set (using the designer rather than doing it myself), but I noticed the other day that th...

virtualenv not working on Mac OSX 10.11 El Capitan

python macos python-2.7 virtualenv osx-elcapitan

I try to create a virtualenv but if fails. I searched at Google and at Stackoverflow but I found nothing helpful. Maybe someone can point me to an answer?