Fetch vs FetchMany in NHibernate Linq provider

本小妞迷上赌 提交于 2019-11-27 05:20:53

问题


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?


回答1:


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)


来源:https://stackoverflow.com/questions/4394692/fetch-vs-fetchmany-in-nhibernate-linq-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!