sql server - Using NHibernate (and Fluent NH) to map datetime-type version columns with better than second accuracy (and not truncate milliseconds) -
i have table datetime-type column version. it's legacy db can't possibly change datetime2 or use different versioning mechanism. nhibernate class mapping datetime c# typed property.
i've seen several questions , forum posts , replies regarding issue, regardless of i've tried, nhibernate keeps truncating milliseconds off datetime value.
here's i'm doing fluent nhibernate:
version(x => x.modifiedon).column("modifiedon") .customtype("timestamp").not.nullable(); and in class that's being mapped, have:
public virtual system.datetime modifiedon { get; set; } the database ms sql 2008, , fluent nh configured such:
fluently.configure() .database(mssqlconfiguration.mssql2008.connectionstring......) what need: working example of how configure fluent nh make nh send datetime values milliseconds (from i've seen in code should 10 ms accuracy). thanks!
the behavior you're describing (truncating milliseconds) nhibernate's default behavior datetime values, sounds if fluent nhibernate ignoring .customtype("timestamp"). please export mapping files , post 1 of *.hbm.xml files here? determine whether problem in nhibernate, fluent nhibernate, or possibly somewhere else. see fluent nhibernate documentation instructions on exporting mapping files.
if fluent nhibernate working correctly, should see similar to
<version name="modifiedon" type="timestamp"> <column name="modifiedon" not-null="true" /> </version> i think instead you'll see type="system.datetime". cause fluent nhibernate code not being executed. posting details how use fluent nhibernate create session factory determine whether that's cause or not.
Comments
Post a Comment