Hello, I have a base Entity type containing the properties - Id and CreatedAt (Datetime). In the required default parameterless constructor I always set CreatedAt = DateTime.UtcNow;
This works fine and acts like intended when creating new instances of my entities for saving etc. But when querying objects from the database the parameterless constructor is also called and CreatedAt is set. CreatedAt is overwriten with the data fetched from the database but I would like to not set it every time querying an object. How can I solve this ? Is there some smart/clever/secret work around for this? The best i can come up with is to mark the parameterless constructor as protected and not set the CreatedAt property, and then create a public constructor with a parameter (that doesnt really matter) that can be used when creating new instances of my objects which should be saved, but it is a very ugly solution. Is there any problems in setting default values in the constructor for properties which is mapped ? For an example I am wondering if it will be a problem if the CreatedAt property is set to be lazyloaded and is never fetched from the database before being saved (updated). Will nhibernate internally know that the CreatedAt property was assigned before the object data was fetched from the database and it should not be used when updating? Best regards Martin ps. www.fluentnhibernate.org just gives me page saying "It works! This is the default web page for this server. The web server software is running but no content has been added, yet." in case project owners/ administrator should look here and isnt aware of it. -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibern...@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.