I need to do the following for the purposes of paging a query in nHibernate:
Select count(*) from
(Select e.ID,e.Name from Object as e where...)
I have tried the following,
select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...)
and I get an nHibernate Exception saying I cannot convert Object to int32.
Any ideas on the required syntax?
EDIT
The Subquery uses a distinct clause, I cannot replace the e.ID,e.Name with Count(*)
because Count(*) distinct
is not a valid syntax, and distinct count(*)
is meaningless.
Do you need e.Id,e.Name?
just do
select count(*) from Object where.....
Solved My own question by modifying Geir-Tore's answer.....
Here is a draft of how I do it:
Query:
ObjectDataSource:
I prefer,
NHibernate 3.0 allows Linq query.
Try this