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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:48:28+00:00 2026-05-25T12:48:28+00:00

I have a case where I need to load about 10 000 objects from

  • 0

I have a case where I need to load about 10 000 objects from database. The data model is something like this:

public class SimulationObject
{
    public Container Container {get;set;}
    public IList<ResultItem> Results {get;set;}
    public IList<PreviewData> PreviewData {get;set;}
    ...
}

public class ResultItem
{
    public IList<SomeDataItem> Items {get;set;}
    ...
}

public class PreviewData
{
    public IList<SomeDataItem> Items {get;set;}
    ...
}

This means that I want to query a list of SimulationObjects from database according to some query, and all of it’s properties (references) and subitems.

The quantities of collections are the following:

  1. SimulationObject – ca 6000 – 1200, depending on parameters in “where”
  2. SimulationObject.Results – ca 5 to 40 items
  3. SimulationObject.Results.Items – ca 0 to 2 items
  4. SimulationObject.PreviewData – ca 0 to 2 items
  5. SimulationObject.PreviewData.Items – ca 1 to 3 items

Normally, I’d do it like this:

var query = from sim in session.Query<SimulationObject>()
        where sim.Container.Id == containerId && ...
            select sim;

query = query.FetchMany(c => c.Results).ThenFetch(o => o.Items)...

However, I also need to fetch “PreviewData” items for that would create a Cartesian product in my query (meaning PreviewDataAndSubItemsCount x ResultsAndSubItemsCount amount of rows returned) which is very ineffective. Also, as I need to load a LOT of SumulationObjects (about 10000 as sayd earlier), I cannot do lazy loading (10000 queries..and there are other difficulties too, so this isn’t even an alternative to consider).

So what are the alternatives ? What strategy would you use to load a complite object graph into memory ?

Thanks.

  • 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-25T12:48:29+00:00Added an answer on May 25, 2026 at 12:48 pm

    Ayende explains one way to do this here (HQL):
    http://ayende.com/blog/4367/eagerly-loading-entity-associations-efficiently-with-nhibernate

    There was also a StackOverflow article that I came across that does this using QueryOver:
    NHibernate Eager Loading with Queryover API on a complex object graph

    I would be very interested in getting additional input from the rest of hte community though. I think this is one area in which NH could improve on.

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

Sidebar

Related Questions

I have a case where I need to load bitmap from a resource dll
I need to bulk load a large amount of data (about 7.000.000 entries) into
Have a use case wherein need to maintain a connection open to a database
I have a case where I need to translate (lookup) several values from the
Imagine this case where I have an object that I need to check a
I have a C++ application that loads lots of data from a database, then
I have a case where I need to serve raw swf files to the
I have a case where I need to select a random item, but I
I have a case where I need to update a jqgrid based on some
I have a business case whereby I need to be able to specify my

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.