Applying attributes to the generated business objects

Apr 12, 2010 at 1:15 PM

Hi,

Does anybody know how additional attributes can be applied to the properties in the POCO generated by the framework. I know you can use System.ComponentModel.DataAnnotations library to apply attributes but I am not sure it will override any of the attributes already present or not. Any samples of how to do this will be helpful.

Thanks,

-Girish

Coordinator
Apr 20, 2010 at 2:33 AM

The best way to handle this is to override the existing generator.

1. You will need to start by reading the following article. http://www.codeproject.com/KB/codegen/nHydrate-Extension.aspx

2. Get the latest code from SVN. I made the DTOGenerator public.

3.  Get the example code from SVN located at. https://nhydrate.svn.codeplex.com/svn/examples/GeneratorExtension. I added a new class OverrideDTOGenerator and OverrideDTOTemplate.