O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Property validation with attributes

Another NHibernate Contribution project, NHibernate Validator, provides data validation for classes. In this recipe, I'll show you how to use NHibernate Validator attributes to validate your entities.

Getting ready

  1. Download the NHibernate Validator binary files from SourceForge at http://sourceforge.net/projects/nhcontrib/files/.
  2. Extract NHibernate.Validator.dll, nhv-configuration.xsd, and nhv-mapping.xsd from the downloaded ZIP file to your solution's Lib folder.
  3. Add both xsd files to the Schema folder of your solution, just as we did with the NHibernate xml schema files in the Mapping a class with XML recipe in Chapter 1.
  4. Complete the Eg.Core model and mappings from Chapter 1.

How to do it...

  1. Create a new class library ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required