2010-08-14 35 views
4

Castle ActiveRecordBeforeLoad事件,但我也需要AfterLoad事件。我知道可以使用NHibernate的PostLoad事件。但我該怎麼做?Castle ActiveRecord和AfterLoad事件

+0

我注意到你已經在你的網站上發佈了一個樣本解決方案:http://blog.afsharm.com/2010/09/using-nhibernate-event-model-in-castle.html - 謝謝! – 2011-02-20 12:48:34

+0

@Lessan,很高興能幫助任何人! – 2011-02-22 04:45:01

回答

0

ActiveRecord的「事件」基於NHibernate interceptorsIInterceptor),而不是NHibernate eventsIInterceptor沒有任何PostLoad,所以ActiveRecord中沒有可覆蓋的AfterLoad方法。

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

+0

那麼在AR中加載一個實體後,我該如何做一些代碼呢? – 2010-08-15 06:09:46

+0

@afsharm:連接IPostLoadEventListener – 2010-08-15 06:39:31

+0

IPostLoadEventListener處於事件模型中。我對嗎?如果是的話,我怎麼能把它掛起來,而你說AR是基於NHibernate的攔截器而不是事件模型? – 2010-08-15 07:57:55