NHibernate事件和生命周期的文档? [英] Documentation of NHibernate events and lifecycle?

查看:174
本文介绍了NHibernate事件和生命周期的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到关于NHibernate事件的好参考,以及每个事件的生命周期?似乎有几个事件,没有适当的文件,很难确定各种事件之间的差异。

Where can I find a good reference on NHibernate events and what the lifecycle for each looks like? There seem to be several events and without proper documentation it's hard to know for sure what differences between the various events are.

当然有明显的像 OnSaveOrUpdate - 但也有不明显的例如 ILoadEventListener vs IPreLoadEventListener vs IPostLoadEventListener

Sure there are obvious ones like OnSaveOrUpdate - but there are also non-obvious ones like ILoadEventListener vs IPreLoadEventListener vs IPostLoadEventListener

推荐答案

我知道的唯一官方文档在这里: a href =http://nhibernate.info/doc/nhibernate-reference/index.html =nofollow> http://nhibernate.info/doc/nhibernate-reference/index.html

The only official documentation that I know of is here: http://nhibernate.info/doc/nhibernate-reference/index.html

以下是描述事件系统的本文档摘录。您提到的事件是基于 ISession 接口中的 Load 方法的侦听器。

The following is an excerpt from this documentation that describes the event system. The events that you mention above are listeners based on the Load method in the ISession interface.


12.2 。事件系统

如果您必须对持久层中的特定事件做出反应,则
您还可以使用NHibernate2事件体系结构。事件系统
可以作为拦截器的替代使用。

If you have to react to particular events in your persistence layer, you may also use the NHibernate2 event architecture. The event system can be used in addition or as a replacement for interceptors.

基本上所有的ISession接口的方法与
an事件。您有一个LoadEvent,FlushEvent等(请参阅XML
配置文件XSD或NHibernate.Event命名空间,以获取已定义事件类型的完整
列表)。当一个请求是这些
方法之一时,ISession生成一个适当的事件,并将其传递给
该类型的配置的事件监听器。开箱即用的这些
监听器执行相同的处理,这些方法始终是
。但是,您可以自由地实现一个
之一的监听器接口的定制(即,LoadEvent由
注册的ILoadEventListener接口实现)处理,在
中,这样它们的实现将负责处理
由ISession提供的任何Load()请求。

Essentially all of the methods of the ISession interface correlate to an event. You have a LoadEvent, a FlushEvent, etc (consult the XML configuration-file XSD or the NHibernate.Event namespace for the full list of defined event types). When a request is made of one of these methods, the ISession generates an appropriate event and passes it to the configured event listeners for that type. Out-of-the-box, these listeners implement the same processing in which those methods always resulted. However, you are free to implement a customization of one of the listener interfaces (i.e., the LoadEvent is processed by the registered implemenation of the ILoadEventListener interface), in which case their implementation would be responsible for processing any Load() requests made of the ISession.

与任何开源工具一样,有时候只需要下载源代码,或者查看注释或代码本身。

As with any open source tool though sometimes you just need to download the source and either look at the comments or the code itself.

除了查看代码之外,还有很多关于nhibernate的书籍,也可能是您的helfpul。

In addition to looking at the code there are numerous books out there on nhibernate that might be helfpul for you as well.

NHibernate 3.0 Cookbook http://www.packtpub.com/nhibernate- 3-0-cookbook / book

NHibernate 3.0 Cookbook http://www.packtpub.com/nhibernate-3-0-cookbook/book

NHibernate 3入门指南 http://www.packtpub.com/nhibernate-3-beginners-guide/book (我推荐这本书)

NHibernate 3 Beginner's Guide http://www.packtpub.com/nhibernate-3-beginners-guide/book (I recommend this book)

使用NHibernate 3.0 http://www.wrox.com/WileyCDA/WroxTitle/Working-with-NHibernate-3-0.productCd-1118112571.html

Working with NHibernate 3.0 http://www.wrox.com/WileyCDA/WroxTitle/Working-with-NHibernate-3-0.productCd-1118112571.html

这篇关于NHibernate事件和生命周期的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆