LINQプロバイダーでNHibernate2.1を使用していますが、このクエリから返される結果には複数のルートノードがあります。
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;
}
Criteria APIを使用すると、DistinctRootEntityResultTransformer()を呼び出して、一意のルートノードを確実に取得できることを知っていますが、ほとんどのクエリをNHibernate LINQプロバイダーに切り替えているところですが、同等。
http://nhforge.org/wikis/howtonh/get-unique-results-from-joined-queries.aspx