I use named SQL query with very complicated syntax and long-timed to execute (using inner selects and MS SQL contains).
Then IQuery query = context.Session.GetNamedQuery("QueryName"); is used.
For selecting only required results following code is used.
query.SetFirstResult(5);
query.SetMaxResults(15);
As I understand, sql query is executed, result set contains all records (all rows) and only 5-15 of them are mapped to objects by NHibernate. Obviously, NHibernate does not add anything to SQL query (for example SELECT TOP x).
Is it right? Does NHibernate uses some specific technic to perform setFirstResult?
Then - is it possible to get the amount of total rows returned (not mapped)? I do not want to execute the same query with select count(*) again in addition to previous call. Is it possible? Probably, what is needed is to get affected rows count only.
Thanks!
|