在 Linq-to-Nhibernate 中,是否可以在 .Select() 之后使用 .Fetch()?
如果我有一个对象 A,其中包含对对象 B 的多对一引用,其中对象 B 包含对象 C 的一对多集合...请考虑以下查询:
IQueryable<A> query = getIQueryableSomehow();
List<B> resultList = query.Where(A => A.whatever == something).Select(A => A.B).Fetch(B => B.C).ToList();
我想做与此类似的操作,但我不断收到此代码的空引用异常。是否有一个偷偷摸摸的技巧来实现这种查询并获取一堆对象 B 集合,或者这是不可能的?
谢谢!
If I had an Object A that contained a many-to-one reference to Object B, where Object B contained a one-to-many collection of Object C... consider the following query:
IQueryable<A> query = getIQueryableSomehow();
List<B> resultList = query.Where(A => A.whatever == something).Select(A => A.B).Fetch(B => B.C).ToList();
I want to do something similar to this, but I keep getting a null reference exception with this code. Is there a sneaky trick to achieve this kind of query AND fetch a bunch of Object B collections, or is it impossible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以指定 Fetch before 加载所有 A,B,C 然后选择 B
you can specify Fetch before to load all A,B,C and then select the Bs