开发者

nhibernate event listener registration

开发者 https://www.devze.com 2023-02-24 21:01 出处:网络
I am trying to override the delete event listener with a custom soft delete listene开发者_高级运维r I wrote; however, I am having issues with the registration process.I have the following in my web.co

I am trying to override the delete event listener with a custom soft delete listene开发者_高级运维r I wrote; however, I am having issues with the registration process. I have the following in my web.config:

  <event type="delete">
    <listener class="NHibernateTest1.Model.MyDeleteEventListener"/>
  </event>

I have tried to register the listener programmatically as well:

  NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
  config.SetListener(ListenerType.Delete, new MyDeleteEventListener());

I tested this and my deletes are still hard deletes, in fact I do not think my listener was even registered. Any ideas what might be going on? Thanks.


You are probably missing the assembly name in the config file. Should be something like:

<event type="delete">
    <listener class="NHibernateTest1.Model.MyDeleteEventListener, YourAssembly"/>
</event>

I have my events setup this way and it works flawlessly.

0

精彩评论

暂无评论...
验证码 换一张
取 消