I am using Fluent Nhibernate and Nhibernate for my current project. I need to record the time to the millisecond. I have this for my mapping
Map(x
We use the same approach as you and it does correctly store the milliseconds. If you weren't always doing it that way though your old records will have lost their milliseconds.
Assuming you want to store milliseconds for all of your DateTime fields, you could use a convention:
public class OurPropertyConventions : IPropertyConvention
{
public void Apply(IPropertyInstance instance)
{
Type type = instance.Property.PropertyType;
if (type == typeof(DateTime) || type == typeof(DateTime?))
instance.CustomType("Timestamp");
}
}
Your mappings can now just be:
Map(x => x.SystemDateTime).Not.Nullable();