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

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

问题描述

Fetch和FetchMany完成NHibernate紧急加载. rel ="noreferrer"> NH Hablow Linq渴望获取,在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 vs FetchMany的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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