Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i do select count(*) from TABLE with nHibernate without queryOver?

Tags:

hql

nhibernate

I am using an older version of nHibernate due to my old version of .net. QueryOver isn't an option. What's an efficient way to count the rows of a table with nhibernate?

like image 753
Gizmo Avatar asked Mar 24 '23 03:03

Gizmo


1 Answers

The HQL you show in your comment is correct:

int count = (int)s.CreateQuery("select count(*) from [classname]").UniqueResult();

This will return the number of rows in the table represented by classname.

like image 84
Jamie Ide Avatar answered Apr 06 '23 18:04

Jamie Ide