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

  • SEARCH
  • Home
  • 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 7667637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:09:28+00:00 2026-05-31T15:09:28+00:00

I’ve got this simple linq query in NHibernate 3.2 and SQLite provider: var all

  • 0

I’ve got this simple linq query in NHibernate 3.2 and SQLite provider:

var all = (from book in Session.Query<Book>() select book)
    .Skip(15)
    .Take(15)                
    .ToList();

This query returns correctly 15 entities, but when I try to eager load a dependent collection with FetchMany like this:

var all = (from book in Session.Query<Book>() select book)
    .FetchMany(books => books.Authors)
    .Skip(15)
    .Take(15)                
    .ToList();

I get only 11 entities returned. Is this a bug or something I’m missing?

Here is the resulting SQL query

select
     book0_.Id as Id2_0_,
     author2_.Id as Id0_1_,
     book0_.Title as Title2_0_,
     book0_.Sort as Sort2_0_,
     book0_.TimeStamp as TimeStamp2_0_,
     book0_.PubDate as PubDate2_0_,
     book0_.Series_Index as Series6_2_0_,
     book0_.Author_Sort as Author7_2_0_,
     book0_.Isbn as Isbn2_0_,
     book0_.Lccn as Lccn2_0_,
     book0_.Path as Path2_0_,
     book0_.Flags as Flags2_0_,
     book0_.Uuid as Uuid2_0_,
     book0_.Has_Cover as Has13_2_0_,
     book0_.Last_Modified as Last14_2_0_,
     author2_.Name as Name0_1_,
     author2_.Sort as Sort0_1_,
     author2_.Link as Link0_1_,
     authors1_.book as book0__,
     authors1_.author as author0__
from 
    books book0_ 
  left outer join 
    books_authors_link authors1_ on book0_.Id=authors1_.book left outer join authors author2_ 
  on authors1_.author=author2_.Id
order by book0_.Id asc
limit 15 /* @p0 */ offset 0 /* @p1 */

This effectively limits the result set to 15 rows and not 15 entities as I intended to.

  • 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-31T15:09:29+00:00Added an answer on May 31, 2026 at 3:09 pm

    skip and take are translated to the equivalents in sql which limit on rows and since you are eager fetching with joins there isn’t much you can do about it.

    to eager fetch the first 15 books you need to:

    var all = Session.Query<Book>()
        .Skip(15)
        .Take(15)                
        .ToList();
    
    var ids = all.Select(b => b.Id).ToList();
    
    // fetch all Authors of the books, now the books in all have initialized Authors
    Session.Query<Book>()
        .Where(b => ids.Contains(b.Id))
        .FetchMany(books => books.Authors)
        .List();
    

    this has 2 roundtrips though

    Update: one roundtrip with QueryOver, maybe you can translate into Linq

    var subquery = QueryOver.Of<Book>()
        .Skip(15)
        .Take(15)
        .Select(b => b.Id);
    
    var all = Session.QueryOver<Book>()
        .WithSubquery.WhereProperty(b => b.Id).In(subquery)
        .Fetch(books => books.Authors).Eager
        .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.