views:

46

answers:

1

Castle ActiveRecord has BeforeLoad event but I need AfterLoad event too. I know it's possible to use NHibernate's PostLoad event. But how can I do this?

A: 

ActiveRecord's "events" are based on NHibernate interceptors (IInterceptor), not NHibernate events. IInterceptor doesn't have any PostLoad, so there's no overridable AfterLoad method in ActiveRecord.

Here are the docs on how to hook up event listeners in ActiveRecord.

Mauricio Scheffer
So how can I do some code just after loading an entity in AR?
afsharm
@afsharm: hook up a IPostLoadEventListener
Mauricio Scheffer
@Mauricio: IPostLoadEventListener is in event model. Am I right? if yes, how can I hook it up while you say AR is based on NHibernate interceptors not event model?
afsharm
@afsharm: see the link I posted to the docs on how to hook up event listeners in ActiveRecord.
Mauricio Scheffer