Ho una domanda come questoLINQ to NHibernate duplicati unisce
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);
La clausola where ha bisogno di essere dopo prendere a causa di this bug. Il problema è che le chiamate Fetch
emettono ulteriori join. In query SQL è simile al seguente:
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
Lo fa join interno per mettere una condizione su CommunityId
e lo fa a sinistra outer join per fare il recupero.
Ho trovato similar question, ma la mia query ha un piano di esecuzione diverso con e senza join aggiuntivi.
È un errore nel provider LINQ? Forse c'è una soluzione?