[NHibernate] DateTime without milliseconds, how to increase precision

Software which I was updating into XXI century had database in which every record contains time stamp about insert or latest update.

In NHibernate – DateTime is saved with precision of seconds. “Old” software was saving with precision of milliseconds, it was requirement to hold that precision.

Help came from StackOverflow.

public class DateTimeMilisecondsConventions : IPropertyConvention
    public void Apply(IPropertyInstance instance)
        Type type = instance.Property.PropertyType;
        if (type == typeof (DateTime) || type == typeof (DateTime?))

After defining class like that we need to include it to configuration. I use FleuntNHibernate so config look like this:

    .ConnectionString(c => c.FromAppSetting("ConnectionString")))
    .Mappings(m =>

Programista, domowy kucharz i "amator amerykańskiej polityki". Zbieram informacje z całej sieci, po odrzuceniu chwastów i dodaniu swojej opinii publikuje na blogu.