Unique join query results with NHibernate LINQ provider

I am using NHibernate 2.1 with the LINQ provider, and the results obtained from this query have several root nodes:

public IList<Country> GetAllCountries() { List<Country> results = (from country in _session.Linq<Country>() from states in country.StateProvinces orderby country.DisplayOrder, states.Description select country) .Distinct() .ToList(); return results; } 

I know that using the API criteria you can call DistinctRootEntityResultTransformer () to make sure you get a unique root node, but I am in the process of switching most of my requests to the NHibernate LINQ provider, and I see no equal.

http://nhforge.org/wikis/howtonh/get-unique-results-from-joined-queries.aspx

+4
source share
1 answer

Using the NorthWind database, I wanted to return individual areas from territories ... This syntax worked correctly.

 (from t in Territories from r in Regions select new { r.RegionDescription }) .Distinct().OrderBy(r => r.RegionDescription) 

There is a post on the Microsoft forum that might help.

+2
source

All Articles