Well that means a lot of queries if MaxSize is 200.
But maybe it is the only way to do it.

Are there any example of this scenario with Criterion?
I guess the use of Future is needed, you want to get the root entity
loaded with its collections as result.

On Aug 27, 8:08 pm, Diego Mijelshon <[email protected]> wrote:
> The answer is right there: "two totally separate queries, first to get just
> the entities, then to load the related associations"
>
> First, one paged query without fetching the collections, then one query per
> collection, filtering with the Ids of the first query.
>
>     Diego
>
> On Fri, Aug 27, 2010 at 09:49, Niclas Pehrsson <[email protected]> wrote:
> > Well it wont work :(
>
> > Ayende repsonded to an comment with this
> > "SetMaxResults, but that might cause issues with the loading.
> > At that point, I might want to execute two totally separate queries,
> > first to get just the entities, then to load the related associations.
> > "
>
> > So how can I solve this?
> > Its a bit annoying, I want to load 200 hundred of thousands, and I
> > want to avoid 200+200 select queries.
> > Any other approaches?
>
> > On Aug 26, 3:03 pm, Diego Mijelshon <[email protected]> wrote:
> > > SetMaxResults and SetFetchMode on _collections_ don't get along.
>
> > > Suggested read:
> >http://ayende.com/Blog/archive/2010/01/16/eagerly-loading-entity-asso...
>
> > >     Diego
>
> > > On Thu, Aug 26, 2010 at 04:50, Niclas Pehrsson <[email protected]>
> > wrote:
> > > > Hi I have an query that looks like this.
>
> > > >            Return (From receipt In _session.Linq(Of
> > > > PointOfSale.Receipt)() _
> > > >                            Where receipt.IsClosed AndAlso Not
> > > > receipt.IsSynchronized _
> > > >                     Select receipt).Take(25).ToList()
>
> > > > Or
> > > >            Dim criterion = _session.CreateCriteria(Of Receipt)
> > > > ().SetMazSize(25).Add(Expression.Eq("IsClosed", True)) _
> > > >                .Add(Expression.Eq("IsSynchronized", False)) _
> > > >                .SetFetchMode("Payments", FetchMode.Eager) _
> > > >                .SetFetchMode("ReceiptEntry", FetchMode.Eager)
>
> > > >            'Return criterion.List(Of PointOfSale.Receipt)()
>
> > > > Both of them first asks the database för the first query options
> > > > IsClosed and Not IsSynchronized, and then It creates an select N+1 for
> > > > each element. How can I do this better so it will be just one or three
> > > > queries that selects top 25 entities?
>
> > > > --
> > > > 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]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > 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]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.

-- 
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.

Reply via email to