Tikam Sangwani
Tikam Sangwani

Reputation: 325

Distinct Query in nhibernate

I am new in nHibernate and i want to convert following sql query in nHibernate criteria

SELECT DISTINCT fReportID, fFiscalYear  
FROM tFCMaster   
WHERE fPropertyID='100'

I tried this:

Session.CreateCriteria<tFCMaster>().Add(Expression.Eq("fPropertyID", PropertyID))
       .SetProjection(Projections.Distinct(Projections.Property("fFiscalYear")))
       .List<tFCMaster>();

help will appreciated.

Upvotes: 0

Views: 1897

Answers (1)

C&#225;ssyo Kist
C&#225;ssyo Kist

Reputation: 11

Try this one.

criteria.SetProjection(Projections.Distinct(Projections.Property("Country")));

Best Regards.

Upvotes: 1

Related Questions