开发者

Fetch vs FetchMany in NHibernate Linq provider

开发者 https://www.devze.com 2023-01-29 08:42 出处:网络
NHibernate eager loading can be done using Fetch and FetchMany, as described in NHibernate Linq Eager Fetching on Mike Hadlow\'s blog.

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 should be used for references and FetchMany for collections.

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

Example:

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

精彩评论

暂无评论...
验证码 换一张
取 消