You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to NhLambdaExtensionsUsers
Hey guys,
I'm making a forum with nhibernate and NHLambdas.
A ForumCategory (eg Sport) has a number of forums (e.g. Football,
Tennis), each forum has a number of associations, like Threads, Latest
Thread.
I want to Eager load all the Forums in a ForumCategory, and also eager
load some of the associations in each forums.
in HQL this works: "from ForumCategory category left join fetch
category.Forums forums inner join fetch forums.NewestThread
newestthread"
However when I try to do this in NHLambdas
criteria.SetFetchMode<ForumCategory>(t => t.Forums.???,
FetchMode.Eager);
because Forums is a collection, the ??? in intellisense gives me the
collection methods Add/Remove/Count... rather than the properties/
associations in a forum, so basically how do I eager load all the
Forums, and then eager load an association eg LatestThread from each
forum?
Richard Brown (gmail)
unread,
Nov 6, 2009, 2:20:58 PM11/6/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
--------------------------------------------------
From: "reach4thelasers" <kev.m....@googlemail.com>
Sent: Friday, November 06, 2009 6:59 PM
To: "NhLambdaExtensionsUsers" <nhlambdaext...@googlegroups.com>
Subject: Eager Load Collection and Association
reach4thelasers
unread,
Nov 7, 2009, 12:45:18 PM11/7/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to NhLambdaExtensionsUsers
Thanks richard, the first one worked great!!
had a bit of trouble with the second one, it worked, but for some
reason didn't populate all the associations.
> Hi Kev,
>
> I think you can use the syntax:
>
> criteria.SetFetchMode<ForumCategory>(t => t.Forums[0].LatestThread)
>
> I think it's also possible (although I could be wrong) to do something like:
>
> criteria.SetFetchMode<ForumCategory>(t => t.Forums)
> .CreateCriteria<ForumCategory>(t => t.Forums)
> .SetFetchMode<Forum>(f => f.LatestThread).
>
> Let me know if that's of any help.
>
> Cheers,
> Richard
>
> P.S., And example of that syntax in the tests is in