0

I'm trying to persist the datetime of creation and update of entites (not relevent to versioning and concurrency) using fluent nhibernate.

To achieve this using nhibernate I would write this mapping tag:

<timestamp name="Timestamp" access="property" unsaved-value="null" />

How can I make fluent nhiberbate generate that mapping tag?

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194

1 Answers1

1

If you mean map a DateTime property as this:

<property name="Timestamp" type="Timestamp"/>

This is the equivalent in Fluent NHibernate:

Map(x => x.Timestamp).CustomType<TimestampType>();
Najera
  • 2,869
  • 3
  • 28
  • 52
  • I am trying to generate the values for the column automatically. When I map the column as you suggested, the value inserted into the DB is null – gilad segal May 12 '15 at 05:38
  • That is not posible, here are some alternatives: http://stackoverflow.com/a/17140292/1486443 and http://stackoverflow.com/a/18919702/1486443 – Najera May 12 '15 at 06:11
  • How come this isn't possible? This is a trivial feature. Anyway, I think I favor using interceptors over triggers. I'll submit a request for this feature at github – gilad segal May 12 '15 at 07:19