views:

279

answers:

2

I have a client -> service -> server, architecture and I want to introduce validation.

I have dtos being passed over the service and get transformed into domain objects on the server.

Say if a user enters in a value and I need to check this value against the database to see if it exists and if so return an error and highlight the field, how would I best go about this?

+2  A: 

It's a pretty complicated topic, but there are frameworks like Rocky Lhotka's CSLA.NET and the upcoming Microsoft WCF RIA Services that attempt to abstract some of the challenges of maintaining a consistent set of validation rules on both the client and server. There really isn't a silver bullet and I suspect any answers that fit in a Stack Overflow response will only scratch the surface so I'll just point you to those two frameworks which may give you some ideas.

You'll also want to look into the IDataErrorInfo interface in .NET which both Windows Forms and WPF can use to communicate errors in business objects back to the UI.

Josh Einstein
+2  A: 

As Josh mentions, there is no silver bullet for this. Here is the approach I used to achieve what you are asking about using Enterprise Library Validation Application block. It's not particularly elegant (which still bugs me!) but it is working.

Tuzo