如何使用 nhibernate 和 LINQ 将多个联接(获取)添加到联接表?
我有这些表/实体
VacationRequestDate表,其中有一个与VacationRequest表链接的VacationRequestId字段
VationationRequest 具有与 PersonPersonId 和 RequestStatusId 字段分别是strong>和RequestStatus。
到目前为止我有这个查询:
IEnumerable<VacationRequestDate> dates = Session.Query<VacationRequestDate>().Fetch(r => r.VacationRequest).ThenFetch(p=>p.RequestStatus).ToList();
这工作正常并与 VacationRequest 连接,然后 VacationRequest 与 RequestStatus 连接,但我不知道如何将额外的 EAGER 联接添加到 VationationRequest 表中。
如果我在末尾添加 Fetch ,它会引用 VacationRequestDate 表
如果我在末尾添加 ThenFetch ,它会引用 RequestStatus 表,
我找不到任何将 VacationRequest 表引用为参考点的 api。
如何使用 nhibernate LINQ 将多个联接添加到联接表?
i have these tables /entities
VacationRequestDate table which has a VacationRequestId field that links with VacationRequest table
VacationRequest has PersonId and RequestStatusId fields that links with Person and RequestStatus respectively.
i have this query so far:
IEnumerable<VacationRequestDate> dates = Session.Query<VacationRequestDate>().Fetch(r => r.VacationRequest).ThenFetch(p=>p.RequestStatus).ToList();
this works fine and joins with VacationRequest and then VacationRequest joins with RequestStatus but i can't figure out how to add an additional EAGER join to the VacationRequest table.
If i add a Fetch at the end, it refers to the VacationRequestDate table
If i add a ThenFetch at the end, it refers to the RequestStatus table
I can't find any api that will refer to the VacationRequest table as the reference point.
how would you add multiple joins to a joined table using nhibernate LINQ ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然由于额外的连接而不是 100% 最佳,但这是可行的:
其他查询方法(HQL、Criteria、不确定 QueryOver)没有此限制。
While not 100% optimal because of an additional join, this works:
The other querying methods (HQL, Criteria, not sure about QueryOver) don't have this limitation.