我们何时必须在NHibernate中使用紧急加载?它的用途是什么? [英] When must we use eager loading in NHibernate? What is it's usage?

查看:76
本文介绍了我们何时必须在NHibernate中使用紧急加载?它的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们何时必须在NHibernate中使用紧急加载?有什么用?

When must we use eager loading in NHibernate? What is it's usage?

推荐答案

一种用法是何时缓存或存储对象图(例如,在ASP.NET Cache中).如果不存储整个图形,则可能会丢失有关分离对象的信息.您当然可以重新附加对象,但是无论如何这可能是数据库的新往返.

One usage is when you will cache or store an object graph (in ASP.NET Cache for instance). If you don't store the whole graph, you would be missing information on a detached object. You can reattach objects of course, but that would probably be a new roundtrip to the database anyway.

如果您不希望加载集合,则需要触摸其中的每一个来调用延迟获取.在这种情况下,急切的获取会有用得多.

If you don't eager load your collections, you would need to touch every one of the to invoke the lazy fetch. In those cases, an eager fetch is much more useful.

这篇关于我们何时必须在NHibernate中使用紧急加载?它的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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