SetMaxResults and SetFetchMode on _collections_ don't get along.
Suggested read:
http://ayende.com/Blog/archive/2010/01/16/eagerly-loading-entity-associations-efficiently-with-nhibernate.aspx
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.