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 8322251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:19:21+00:00 2026-06-08T23:19:21+00:00

I have an API set up in my project for a grid to call

  • 0

I have an API set up in my project for a grid to call to get audit records to display to an admin. The grid has infinite scrolling set up and uses oData built into mvc4. So, it will make a call to the api with $top equal to the number of rows it is supposed to get and $skip set to get to the proper page.

Inside the API, I make this call to nhibernate to get an IQueryable to return for MVC4 to do it’s dark oData magic:

m_session.Query<AuditInfo>().FetchMany(x => x.Parameters).Fetch(x => x.AuditType).Fetch(x => x.Status)

In this, AuditInfo has a collection of parameters hanging off it, as well as lookup tables for the type and status.

My issue is that if I ask for 30 rows, it will return some number <= 30. I’ve been able to trace this a little bit, and the problem seems to be that nhibernate has the TOP and JOIN statements in the same query, so when an audit has more than one parameter on it, it creates a copy of the audit to hold the second parameter for returning it. Doing this takes up a space in the TOP(30) that the query allows for. Then, when it gets back to nhibernate, it appears that it merges these rows, leaving me with a collection that has less records than I wanted.

My question here is: How can I set this call up so I can get an accurate number of records without resorting to fetching the parameters separately and having n+1 queries?

  • 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-06-08T23:19:24+00:00Added an answer on June 8, 2026 at 11:19 pm

    basicly you can’t easyly because that is how sql works. leave out the FetchMany and it should work using Select N+1. To remedy that you can tweak the collection batch-size so NH will load more than one collection of the same type at once.

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

Sidebar

Related Questions

I have a Django project set up with Jenkins. One of my apps has
I have an API that filters a set of objects based on the ID
I'm using the the new UIAppearance API and have successfully set the tint color
I have an API call that returns a byte array. I currently stream the
I have two maven projects: project-api project-impl project-impl's POM specifies a dependency on project-api.
I have multiple projects that need to pass user login information to common-api project
I have taken on a project from a client which requires me to set
In a Win32 API C++ project, I have a dialog with a tab control
I want to set in project properties build target 2.2 (api level 8) In
I'm building a RESTful API for a personal project and the administrative area uses

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.