NHibernate Notes3_How to set a default value of column

To set a default value of column with "datetime" type we need to take the advantage of setting the default value of the column within the native DB. In NHibernate we should the set the attritute "generated" to be "alway" or "insert" which will tell NHibernate to fullfill the value of the column with the value assigned from the native DB. Actually there are three value options for the "generated" attribute.
As it described in "NHibernate Reference Documentation". They are:
1. never (the default) - means that the given property value is not generated within the database.
2. insert - states that the given property value is generated _disibledevent=>Section 5.1.7, “version (optional)” and Section 5.1.8, “timestamp (optional)” properties can be marked as generated, this option is not available there...
3. always - states that the property value is generated both _disibledevent=> generated="always" type="DateTime" >

And you can download my sample project from the link below. You can run the Unit Test to build the Test DB with method "Can_generate_schema" and test it with method "AddOrderTest" in "TestNH" project. You can _disibledevent=>EasyNH.zip
Tags: 

延伸阅读

最新评论

发表评论