Hi Markus

I actually tried this, but the OnUpdate/OnSave event doesn't seem to
be called when i try to save/update an entity.

On Jan 6, 3:50 pm, "Markus Zywitza" <[email protected]> wrote:
> Hello Mark
>
> TimeStamp is not an option for you, as you can have only one timestamp
> property per entity. Easiest would be subclassing ActiveRecordBase in
> that way:
>
> public abstract class TimeStampedActiveRecordBase<T>:ActiveRecordBase<T>
> {
>   public override void OnUpdate() {Modified = DateTime.Now}
>   ...
>
> }
>
> If you don't want to use a common base class, you should use
> NHibernate eventlisteners. Those must be added programmatically during
> initialization of ActiveRecord as the AR config doesn't support adding
> it per config.
>
> -Markus
>
> 2009/1/6 Mark Jensen <[email protected]>:
>
>
>
> > Hi
>
> > I usually timestamp everything that I persist into the database with
> > DateTime, I use two properties named Created and Modified.
>
> > After going though various solutions I still haven't come up with
> > something really I like.
>
> > 1.
>
> > override every Save,Update, Create method and add something like
>
> > created = DateTime.Now; (should only be set when created)
> > modified = DateTime.Now;
>
> > 2.
>
> > using the protected override bool BeforeSave(IDictionary state){}
>
> > wich only seems to be called in some cases (haven't figures out what)
>
> > 3.
>
> > I have also looked at the Timestamp/Version attribute, but it doesn't
> > seem to let me control when it should be used (eg. on save, update,
> > create)
>
> > Have I missed something? or do I really have to go with number 1,
> > since that one seems to give me the most control.
>
> > best regards,
> > Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to