Generated.Insert() on DateTime in SQL Server is not generating on INSERT
Forehead is bloody from trying to get this mapping to generate the datetime on INSERT:
public class InstanceMap : ClassMap
{ Id(x => x.Id, "Id").GeneratedBy.GuidComb(); Map(x => x.CreatedBy); Map(x => x.CreatedOn).Generated.Insert(); Map(x => x.ModifiedBy); Map(x => x.ModifiedOn).Generated.Always(); Map(x => x.Description).Length(100); ...
I'm using FluentNHibernate 1.0.0.593 and NHibernate 2.1.0.4.
Support Staff 2 Posted by Paul Batum on 17 May, 2010 04:47 AM
Simply telling nhibernate that the particular property is generated on insert is not enough to actually get the current date and time saved into the column. The responsibility of generating the value lies with the DB. Generated.Insert just tells NH that it should perform a select to reload the object after its performed an insert.
http://www.nhforge.org/doc/nh/en/#mapping-generated
Support Staff 3 Posted by Paul Batum on 18 May, 2010 12:02 PM
Hey, thats cool, I didn't know about Default. Nice one.