NHibernate Linq 提供程序中的 Fetch 与 FetchMany [英] Fetch vs FetchMany in NHibernate Linq provider

查看:24
本文介绍了NHibernate Linq 提供程序中的 Fetch 与 FetchMany的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NHibernate 预先加载可以使用 FetchFetchMany 完成,如 NHibernate Linq Eager Fetching 在 Mike Hadlow 的博客上.

NHibernate eager loading can be done using Fetch and FetchMany, as described in NHibernate Linq Eager Fetching on Mike Hadlow's blog.

这两种方法有什么区别,分别在什么情况下使用?

What is the difference between these two methods and under what circumstance would each be used?

推荐答案

Fetch 用于引用,FetchMany 用于集合.

Fetch should be used for references and FetchMany for collections.

这一点特别重要,因为只有 FetchMany 可以与 ThenFetchMany 结合来获取孙子"集合.

This is particularly important because only FetchMany can be combined with ThenFetchMany to fetch "grandchildren" collections.

示例:

session.Query<User>()
       .FetchMany(u => u.Orders)
       .ThenFetchMany(o => o.OrderItems)

这篇关于NHibernate Linq 提供程序中的 Fetch 与 FetchMany的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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