Finally I realised that implementing Expand for multiple HasMany
relations would be realy complicated and ineffcient...
In my case if each team had 20 players that would mean it had to run a
query returning 20x20 players then filter it
It makes more sense to use
                    NHibernateUtil.Initialize
(this.match.HomeTeam.Players);
                    NHibernateUtil.Initialize
(this.match.AwayTeam.Players);
witch would return 41 rows total (for 3 queries)
and would get worse for larger teams

On Oct 12, 12:40 am, Catalin DICU <[email protected]> wrote:
> Hello,
> When executing the following code I only get two players for each team
> and for the first team I even get two times the same player (there are
> more than 2 players in each team)
>
>                     INHibernateQueryable<Match> queryable =
> session.Linq<Match>();
>                     queryable.QueryOptions.RegisterCustomAction(c =>
> c.SetResultTransformer(new DistinctRootEntityResultTransformer()));
>                     queryable.Expand("HomeTeam");
>                     queryable.Expand("HomeTeam.Players");
>                     queryable.Expand("AwayTeam");
>                     queryable.Expand("AwayTeam.Players");
>
>                     this.match = queryable.Single(m => m.Id == 1);
>
> Is there a way to eager load all players ? Maybe wih plain criteria
> API ?
>
> For the moment I'm using this workaround but that's two more queries:
>
>                     INHibernateQueryable<Match> queryable =
> session.Linq<Match>();
>                     queryable.Expand("HomeTeam");
>                     queryable.Expand("AwayTeam");
>
>                     this.match = queryable.Single(m => m.Id == 1);
>
>                     Player[] hack1 = match.HomeTeam.Players.ToArray();
>                     Player[] hack2 = match.AwayTeam.Players.ToArray();
>
> Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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