Newbie
Newbie

Reputation: 7249

How to generate "select count(*)as y from (select distinct x, y from tableName) as t" using NH?

Any ideas on how to generate the follow query with Nhibernate using the Criteria API?

select count(*)as z from (select distinct x, y from tableName) as t

or

select count(distinct (x , y)) as z FROM tableName

or

some other query that returns the same results.

Upvotes: 3

Views: 313

Answers (1)

Sly
Sly

Reputation: 15227

You can try to generate such a query with the help of ICriteria API and Projection. What you are going to need are Projections.RowCount(), Projections.Distinct(), Projections.Property()

Upvotes: 3

Related Questions