Hi there!
This is my first message in this group.
I'm using NHibernate 3 Alpha, trying to use the Fetch() extension method
over IQueryable<>:
var categorias = this.context.Query<Categoria>();
var queryCategorias = from c in categorias
from i in c.Itens
from iu in i.ItensUsuario
where c.Tipo == tipoCategoria &&
(i.Default || iu.Usuario.Id == idUsuario)
select c;
var listCategorias = queryCategorias.Fetch(c => c.Itens).ToList();
The SQL produced correctly "fetches" the child elements for each parent.
However, two joins are produced for the same table: a INNER JOIN (itens1)
and a LEFT OUTER JOIN (itens3):
select
categoria0_.ID_CATEGORIA as ID1_3_0_, itens3_.ID_ITEM as
ID1_10_1_, categoria0_.DSC_NOME as DSC2_3_0_, categoria0_.TIP_DECORACAO as
TIP3_3_0_, categoria0_.DAT_INSERCAO as DAT4_3_0_,
itens3_.DSC_NOME as DSC2_10_1_, itens3_.DSC_RESUMO as DSC3_10_1_,
itens3_.DSC_PATH_ARQUIVO_HOME as DSC4_10_1_,
itens3_.DSC_PATH_ARQUIVO_CUSTOMIZACAO as DSC5_10_1_,
itens3_.DSC_PATH_ARQUIVO_CABANA as DSC6_10_1_, itens3_.IND_DEFAULT
as IND7_10_1_, itens3_.ID_CATEGORIA as ID8_10_1_, itens3_.ID_CATEGORIA as
ID8_0__, itens3_.ID_ITEM as ID1_0__
from "NST_CATEGORIA" categoria0_
inner join "NST_ITEM" itens1_ on
categoria0_.ID_CATEGORIA=itens1_.ID_CATEGORIA
inner join "NST_ITEM_USUARIO" itensusuar2_ on
itens1_.ID_ITEM=itensusuar2_.ID_ITEM_USUARIO
left outer join "NST_ITEM" itens3_ on
categoria0_.ID_CATEGORIA=itens3_.ID_CATEGORIA
where categoria0_.tip_decorac...@p0 and (itens1_.IND_DEFAULT=1 or
itensusuar2_.id_usuar...@p1);@p0 = 'C' [Type: StringFixedLength (0)], @p1 =
1 [Type: Int32 (0)]
I'd like to have only one join for each table. Is there a solution or
workaround for this?
Thanks in advance,
Thiago Alves
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.