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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:33:11+00:00 2026-05-24T11:33:11+00:00

We have a query we’re attempting to write for paging, where we want to

  • 0

We have a query we’re attempting to write for paging, where we want to use Fetch to eager load a collection for an object, then return a paged list of that object. The query below does not work because when we look in the profiler, it skips the Skip and Take settings, and just returns the list of objects (eagerly loaded):

var result = _repostitory.All<MediaFile>()
            .Skip(10)
            .Take(10)
            .Fetch(mf => mf.Tags);

Everything compiles and executes but, the skip and take parts are ignored and all the data is being brought back. Is it possible to use Fetch in conjunction with Skip and Take for paging?

  • 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-24T11:33:12+00:00Added an answer on May 24, 2026 at 11:33 am

    Have you tried calling fetch before skip and take

    var result = _repostitory.All<MediaFile>()
    .Fetch(mf => mf.Tags)            
    .Skip(10)
    .Take(10);
    

    From what I remember NH cannot handle join eager loading with limits on the query (it has to do with SQL and not NH). It might work with sub select though.

    **UPDATE

    Consider this example

    TableA
    -------------
    Id|Value
    -------------
    1 |Value1
    2 |Value2
    3 |Value3
    
    TableB
    -------------------------
    ChildId|ParentId|ChildValue
    -------------------------
    1      |       1|Value1
    2      |       1|Value2
    3      |       2|Value3
    4      |       2|Value4
    5      |       3|Value5
    6      |       3|ValueA
    7      |       3|ValueA
    8      |       3|ValueA
    
    
    
    SELECT * FROM TableA LEFT JOIN TableB ON TableA.Id = TableB.ParentId
    
    Result
    --------------------------------------
    Id|Value |ChildId|ParentId|ChildValue
    --------------------------------------
    1 |Value1|1      |       1|Value1
    1 |Value1|2      |       1|Value2
    2 |Value1|3      |       2|Value3
    2 |Value1|4      |       2|Value4
    3 |Value1|5      |       3|Value5
    3 |Value1|6      |       3|ValueA
    3 |Value1|7      |       3|ValueA
    3 |Value1|8      |       3|ValueA
    
    
    SELECT TOP 2 * FROM TableA LEFT JOIN TableB ON TableA.Id = TableB.ParentId
    
    Result
    --------------------------------------
    Id|Value |ChildId|ParentId|ChildValue
    --------------------------------------
    1 |Value1|1      |       1|Value1
    1 |Value1|2      |       1|Value2
    

    Therefore the .Take(2) will return one object with two children (Id 1). Where you would want to return the first two objects (Id 1,2) with their children.

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

Sidebar

Related Questions

I have query that runs in the controller: $data['query'] = $this->Member->select_sql($id); $this->load->view('myform'); and then
I have a query sortable collection of images, ie. the items is set to
I have this query this.FixturePartidoPuntaje.Load(); var partidos = from q in this.FixturePartidoPuntaje where (
I have query regarding the disposing of an object. The scenario is as follows.
I have query building plsql code. I use bind variables and associative array to
Let's say I have query structured like below which indicates dates search.asp?date=091210 I want
I want to have query like this in mysql: select a.x, a.y, a.foo, sum(a.bar)
i have query that maybe haven't any element on sequence and i want to
I have query with two MtM relations: $em = $this->getEntityManager(); $qb = $em->createQueryBuilder(); $qb
I have query table copyQuery which has Soil Condition has one of the columns,

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.