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