Tengo una consulta como estaLINQ to NHibernate duplicados se une
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 cláusula where tiene que ser después de ir a buscar debido a this bug. El problema es que las llamadas a thouse Fetch
generan uniones adicionales. En consulta SQL tiene el siguiente aspecto:
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
Hace combinación interna para poner en una condición CommunityId
y qué combinación externa izquierda a hacer ir a buscar.
He encontrado similar question, pero mi consulta tiene un plan de ejecución diferente con y sin uniones adicionales.
¿Es un error en el proveedor de LINQ? Tal vez hay una solución?