c# - LINQ to Nhibernate 重复连接

标签 c# .net linq nhibernate linq-to-nhibernate

我有这样的问题

var orderedQueryable = this.participationRequests
           .Fetch(x => x.CommunityEvent)
           .Fetch(x => x.CommunityMember)
                .ThenFetch(x => x.User)
           .Where(x => x.CommunityMember.Community.Id == communityId)
           .OrderBy(x => x.CreateDate);

由于 this bug,where 子句需要在 fetch 之后. 问题是 thouse Fetch 调用会发出额外的连接。在 SQL 查询中如下所示:

select *
from   ParticipationRequests participat0_
       left outer join CommunityEvents communitye1_
         on participat0_.CommunityEventId = communitye1_.Id
       left outer join CommunityMembers communitym2_
         on participat0_.CommunityMemberId = communitym2_.Id
       left outer join Users user3_
         on communitym2_.UserId = user3_.Id
       inner join CommunityMembers communitym4_
         on participat0_.CommunityMemberId = communitym4_.Id
       inner join CommunityMembers communitym5_
         on participat0_.CommunityMemberId = communitym5_.Id
       inner join Communities community6_
         on communitym5_.CommunityId = community6_.Id
where  community6_.Id = 2002 /* @p0 */
order  by participat0_.CreateDate asc

它执行内部联接以在 CommunityId 上放置条件,并执行左外部联接以执行提取。

我找到了 similar question ,但我的查询有不同的执行计划,有和没有额外的连接。

这是 LINQ 提供程序中的错误吗?也许有解决方法?

最佳答案

Added issue在休眠 jira 上

关于c# - LINQ to Nhibernate 重复连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8152298/

相关文章:

C# HTTP GET 请求返回隐藏字符

c# - 通过 REST 进行 DDD 更新

c# - .NET 进程间 "events"

c# - 如何将 Group By SQL 转换为 LINQ?

c# - 重命名正在运行的应用程序 - 危险吗?

c# - 扩展任务管理器 Windows 8

c# - 在 emgu CV 中使用 SURF 进行对象识别

c# - 浮点精度可以依赖于线程吗?

mysql - linq lambda 复合键 where 和 group by

c# - 低效的 Linq 语句