gpt4 book ai didi

c# - NHibernate 事件和生命周期的文档?

转载 作者:行者123 更新时间:2023-11-30 22:15:15 26 4
gpt4 key购买 nike

我在哪里可以找到有关 NHibernate 事件以及每个事件的生命周期的良好引用资料?似乎有几个事件,如果没有适当的文档,很难确定各种事件之间有什么区别。

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

最佳答案

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

以下是该文档的节选,描述了事件系统。您上面提到的事件是基于 ISession 接口(interface)中的 Load 方法的监听器。

12.2. Event system

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.

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.

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

除了查看代码之外,还有许多关于 nhibernate 的书籍可能对您也有帮助。

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

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

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

关于c# - NHibernate 事件和生命周期的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18091340/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com