Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 507897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:51:06+00:00 2026-05-13T06:51:06+00:00

When paging data, I want to not only return 10 results, but I also

  • 0

When paging data, I want to not only return 10 results, but I also want to get the total number of items in all the pages.

How can I get the total count AND the results for the page in a single call?

My paged method is:

public IList GetByCategoryId(int categoryId, int firstResult, int maxResults)
{

        IList<Article> articles = Session.CreateQuery(
            "select a from Article as a join a.Categories c where c.ID = :ID")
            .SetInt32("ID", categoryId)
            .SetFirstResult(firstResult)
            .SetMaxResults(maxResults)
            .List<Article>();



        return articles;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:51:06+00:00Added an answer on May 13, 2026 at 6:51 am

    The truth is that you make two calls. But a count(*) call is very, very cheap in most databases and when you do it after the main call sometimes the query cache helps out.

    Your counter call will often be a little different too, it doesn’t actually need to use the inner joins to make sense. There are a few other little performance tweaks too but most of the time you don’t need them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do paging of lists of data with ruby on rails. Basically,
I use a GridView control which uses paging and inline editing. I am not
When using DataSources in ASP.net applications, paging and sorting along with GridView only works
I am using postbacks to perform paging on a large amount of data. Since
Task: implement paging of database records suitable for different RDBMS. Method should work for
How to do paging in Pervasive SQL (version 9.1)? I need to do something
I am using paging on a GridView that is tied to a List<Employee> .
Is it possible to using paging functionality in Linq queries? Let's say I have
I'm trying to do some basic paging in MSSQL. The problem I'm having is
ASP.NET: Could anyone provide some C# paging codes in Repeater or ListView controls for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.