code_junkie

Projections.RowCountInt64() returns 0 when i set SetFirstResult

Nov 13th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. SELECT TOP 3 id22_0_, Name22_0_, LastName22_0_, Descript4_22_0_, Phone22_0_, Mobile22_0_,
  2. Email7_22_0_, Email8_22_0_, AddDate22_0_, Country22_0_ FROM (SELECT ROW_NUMBER() OVER(ORDER
  3. BY __hibernate_sort_expr_0__) as row, query.id22_0_, query.Name22_0_, query.LastName22_0_,
  4. query.Descript4_22_0_, query.Phone22_0_, query.Mobile22_0_, query.Email7_22_0_,
  5. query.Email8_22_0_, query.AddDate22_0_, query.Country22_0_, query.__hibernate_sort_expr_0__
  6. FROM (SELECT this_.id as id22_0_, this_.Name as Name22_0_, this_.LastName as LastName22_0_,
  7. this_.Description as Descript4_22_0_, this_.Phone as Phone22_0_, this_.Mobile as
  8. Mobile22_0_, this_.Email1 as Email7_22_0_, this_.Email2 as Email8_22_0_, this_.AddDate as
  9. AddDate22_0_, this_.Country as Country22_0_, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__
  10. FROM Customer this_) query ) page WHERE page.row > 3 ORDER BY __hibernate_sort_expr_0__
  11.  
  12. SELECT TOP 3 y0_ FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as
  13. row, query.y0_, query.__hibernate_sort_expr_0__ FROM (SELECT count(*) as y0_,
  14. CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM Customer this_) query ) page WHERE
  15. page.row > 3 ORDER BY __hibernate_sort_expr_0__
  16.  
  17. ISession session = NHibernateHttpModule.CurrentSession;
  18.  
  19. var countCriteria = CriteriaTransformer.TransformToRowCount(query);
  20. rowCount = Convert.ToInt64(countCriteria.GetExecutableCriteria(session).UniqueResult());
  21.  
  22. query.SetMaxResults(pageSize).SetFirstResult(pageIndex * pageSize);
  23. var customers = query.GetExecutableCriteria(session).List<Customer>();
Add Comment
Please, Sign In to add comment