Hi, 

I have a table that looks like

Country 1..M CountryLocale
1
..
M
City 1..M CityLocale

I try to fetch a city from the database with its locales, the country and 
the country locales.

This was the query I used:

City city = Session.Query<City>()
                              .Where(x => x.Id == id)
                              .Fetch(c => c.Country)
                              .ThenFetchMany(c=>c.CountryLocales)
                              .FetchMany(x => x.CityLocales)
                              .AsEnumerable()
                              .FirstOrDefault();

This results in double records in both the locale entities.

By accident (because I was messing a bit around) I ran a bit later this 
query:

City city = Session.Query<City>()
                              .Where(x => x.Id == id)
                              .Fetch(c => c.Country)
                              .FetchMany(x => x.CityLocales)
                              .AsEnumerable()
                              .FirstOrDefault();

This does the trick, though I do not explicit tell to load the Country 
locales. I'm happy that it works, but would like to understand what I did 
wrong and/or what is going on.

Regards,
Patrick

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to