Validate in nHydrate

Jul 21, 2010 at 4:31 AM


How I can add business rule to object in nHydrate?


Jul 29, 2010 at 2:11 PM

Do you want to add a business rule like business logic? If so, each object has a partial class where you can add custom code that will be complied into the API. If it is more complex you will probably need a business layer. What exactly are you trying to do?

Jul 29, 2010 at 2:31 PM
yes, but i dont know how to add custom code to partial class. Can you write an example code? In nHydrate, how to add bussiness logic like Validation of Enterprise Library? thanks.
Dec 3, 2010 at 1:18 AM

If you look at the generated code there are 2 files for each class. The file that ends with "Generated.cs" is the gen-always file and you should not touch it. The parent file (which is a stub) can be changed and it is gen-once file. For example if you have a "Customer" table you will see a "Customer.cs" and a "Customer.Generated.cs" file. These are the 2 partial regions for 1 class in 2 files.

Dec 3, 2010 at 6:43 AM

I added business rule to cs file, but have a problem: when i change database, i have generate code again and these business rule added will be empty (i think it overwrite existing file)

can you help me to resolve this problem

Dec 3, 2010 at 12:04 PM

The empty partial stub class files are not re-generated. What is the full name of the file in question. Tell me the full path from the project down. Also please confirm that you add some text to this file, re-generate and you do or do not see that text still in the file. This would let me know what kind of file it is. I cannot figure out how your file could get overwritten if it is not a ".Generated.cs" file.