Validating data using data annotations

Validation of your data before persisting it is a requirement for almost every application. By using validation on your Entities, you make sure that no invalid data is persisted to your datastore. When you don't implement validation, there's a risk that a user will input wrongly formatted or plain incorrect data on the screen and even persist this data to your datastore. This is something you should definitely avoid. In this recipe, you'll learn how to validate data using data annotation attributes that you can use on your Entities.

Getting ready

This recipe uses the AdventureWorks Lite database—a free database you can download from http://www.codeplex.com/MSFTDBProdSamples. To follow this recipe, you need ...

Get Silverlight 4 Data and Services Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.