"I want to fetch OneToManyB for several parents."

..or rather, you want to fetch EntityB:s where the Parent.Id is in a list.
Make the query like that, instead of using fetches etc.

/G


On Mon, Dec 28, 2020 at 10:11 AM Tobias Eriksson <
[email protected]> wrote:

> Hi,
> Is it possible to initialize collections without fetching parents?
>
> For example with following mapping
>
> public class EntityAMap : ClassMapping<EntityA>
> {
>     public EntityAMap()
>     {
>         Id(m => m.Id);
>         Bag(m => m.OneToManyB, cm =>
>         {
>             cm.Inverse(true);
>         }, m => m.OneToMany());
>     }
> }
>
> I want to fetch OneToManyB for several parents.
> The closest I have come is using ChildFetch
>
> session.QueryOver<EntityA>()
>                 .Fetch(SelectMode.ChildFetch, e => e)
>                 .Fetch(SelectMode.Fetch, e => e.OneToManyB)
>                 .Where(e => e.Id.IsIn(ids))
>                 .List();
>
> but then there still is an unnecessary join with the parent table
>
> SELECT this_.id                as id1_0_1_,
>        onetomanyb2_.Parent     as parent2_2_3_,
>        onetomanyb2_.id         as id1_2_3_
> FROM   EntityA this_
>        left outer join EntityB onetomanyb2_
>          on this_.id = onetomanyb2_.Parent
> WHERE  this_.id in (1,2,3)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nhusers/adc83311-4f4a-4048-bdb9-87cf28e8d23dn%40googlegroups.com
> <https://groups.google.com/d/msgid/nhusers/adc83311-4f4a-4048-bdb9-87cf28e8d23dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nhusers/CAAOnFsN4Kq9dDZ11GNXs96v0jLKnKf%3D5tLNFC7NbfWfBdYgWLA%40mail.gmail.com.

Reply via email to