NHibernate拦截器 - 它是什么 [英] NHibernate Interceptor - What is it
问题描述
什么是NHibernate拦截器,它在应用程序中提供什么目的?
What is NHibernate Interceptor, and what purpose does it serve in an application?
此外,在本文中,我学到了使用NHibernate使启动时桌面应用程序更慢,所以为了避免这种情况,我需要保存配置文件,然后从保存的文件加载它。我该怎么办?
Also, in this article, I learned that using NHibernate makes a desktop application slower at startup, so to avoid this, I need to save the configuration in a file, and later load it from the saved file. How can I do that? I didn't find any examples in that tutorial.
推荐答案
拦截器允许您在实体被检索/执行时执行额外的功能,删除/更新/插入到数据库...
An interceptor allows you to execute additional functionality when an entity is retrieved / deleted / updated / inserted in the DB ...
关于使您的应用程序变慢:
我建议您只看看优化启动时间,当它真的成为一个问题。
About making your app slower: I'd suggest that you only have a look at optimizing start-up time, when it really becomes a problem.
当你构建一个会话工厂时,NHibernate会解析所有的映射,这是一个有点贵的操作。但是,只要你的实体数量有限,性能影响不大。
我从来没有必要优化NHibernate的初始化,因为启动时间很慢。
When you build a session-factory, NHibernate will parse all the mappings, and that is an operation that is a bit expensive. But, as long as you have a limited number of entities, the performance hit isn't that big.
I have never ever had to optimize the initialization of NHibernate, because of slow startup times.
我建议您首先专注于您的应用程序的核心 - 您要解决的问题 - 然后看看如何可以改善启动性能。
(如果你必须这样做)。
I'd suggest that you first concentrate on the core of your application -the problem you're trying to solve- and afterwards have a look on how you could improve startup performance. (If you'll ever have to do it).
这篇关于NHibernate拦截器 - 它是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!