Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate Criteria Query - Select Distinct

I have a Person entity belongs to a person has a Country, I want to select all the distinct countries that have people in them. Easy in HQL

select distinct p.Country from Person p

How can I do this using a Criteria Query?

like image 365
reach4thelasers Avatar asked Nov 18 '09 01:11

reach4thelasers


1 Answers

criteria.SetProjection(Projections.Distinct(Projections.Property("Country")));
like image 124
Derek Slager Avatar answered Nov 02 '22 08:11

Derek Slager