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);
的查詢where子句必須取後因this bug。 問題是,撥號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提供程序中的錯誤嗎?也許有一個解決方法?