I feel like there is a better way to do this than how I am doing it now.
I am using Silverlight 4, RIA and EF (with an Oracle adapter). I am inserting a record into a table and doing a lot of validation on it with Validation attributes, but I have one piece of validation that requires querying the DB to check existing records before the new one can be inserted (this seems like it should be common and easy requirement, no?)
Right now, I am doing this client-side with an Invoke method on the DomainService. This seems lame and dumb. But I can’t figure out how to do this server-side where it really belongs.
It seems like there should be a way to handle all of this server-side and inform the client of a validation error, but I can’t quite figure it out and hardly anyone seems to approach this one particular validation scenario.
WCF RIA provides a means to attach validation to entities on the serverside. You build a class as detailed below naming it Rules.
I’ve put together an example app that shows adding validation client and server side with RIA.
You can download it here.