I have found the solution below :

           IMultiCriteria vMC = CurrentSession.CreateMultiCriteria();
           vMC.Add<Continent>("continent",
CurrentSession.CreateCriteria<Continent>().SetFetchMode("Countries",
FetchMode.Eager).SetResultTransformer
(Transformers.DistinctRootEntity));
           vMC.Add<Country>("country",
CurrentSession.CreateCriteria<Country>().SetFetchMode("Cities",
FetchMode.Eager));

It's not as fast as I hoped it would be, but I'm not sure it's
possible to do better than this.


On 8 oct, 18:13, Stephane Farges <[email protected]> wrote:
> Hi,
>
> I have a problem with selecting a deep object graph without Select N+1
> or cartesian product.
> The model contains the classes Continent, Country and City. Each
> Continent contains a list of Country, and each Country contains a list
> of City, with bidirectionnal associations(Country has a Continent
> property and City has a Country property).
>
> I want to load a list of all the Continents, with all the countries
> and cities. I know it is a lot of objects(around 2500 in total), but I
> don't have any other choice, and it was previously done with ADO.NET
> with acceptable performance.
>
> I started by doing it the wrong way and I got either the Select N+1
> problem or the Cartesian product problem, and it was not fast enough.
>
> So I tried to do the following :
>
>            IMultiCriteria vMC = CurrentSession.CreateMultiCriteria();
>            vMC.Add<City>("city", CurrentSession.CreateCriteria<City>
> ());
>            vMC.Add<Country>("country",
> CurrentSession.CreateCriteria<Pays>());
>            vMC.Add<Continent>("continent",
> CurrentSession.CreateCriteria<Continent>());
>
> which gives good performance, but doesn't work because the relations
> are not initialized.
>
> I have read this :
>    http://ayende.com/Blog/archive/2007/06/20/Efficently-loading-deep-obj...
> but I'm not sure it applies in my case
>
> Any idea how I can do this ?
>
> Thanks,
> Stephane Farges.
--~--~---------~--~----~------------~-------~--~----~
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