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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:42:29+00:00 2026-05-18T11:42:29+00:00

I have this scenario: class A { public virtual int Id { get; set;

  • 0

I have this scenario:

class A
{
    public virtual int Id { get; set; }
    public virtual B Child { get; set; }
}

class B
{
    public virtual int Id { get; set; }
}

In the mapping of class A, I have a reference to class B:

map.Reference(a => a.Child).LazyLoad();

Now when I do something like:

Session.Query<TypeOfA>().Select(a => a);

Apart from the normal select * from ATable I get n selects from the BTable for each A line. Is like lazy loading is not working.

My questions are:

  1. How to I make the lazyload work here ?
  2. Can I bring the A entities and B entities in a single query ?

Thank you,

  • 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-18T11:42:29+00:00Added an answer on May 18, 2026 at 11:42 am

    Lazy loading is switched on by default and should actually work. If there would be a problem, for instance if it can’t generate the proxy for class B, it would complain when creating the session factory.

    Are you sure that the queries for B are done by the query itself, and not be subsequent access to A?

    You could optimize the access to B in two ways: fetch them together with A in a single query. (I don’t know fluent, this is the xml way to configure it:)

    <many-to-one fetch="join" ...>
    

    This has some problems when used with lists and could also blow up your query a lot. It is of course not lazy loading at all.

    Another, very nice and powerful optimization is batch fetching. It allows the instances to be fetched in separate queries, but fetches several of them at once.

    <class name="B" batch-size="20" ...>
    

    This would fetch 20 B’s at once in one query. It is also available for lists:

    <one-to-many fetch-size="20" ...>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario: public class Login { public virtual int Id {
I have a similar scenario as this one: public class TestLinq2Xml { private XElement
Have this scenario: public class Base { public string Name; } public Class ClassA
i have this scenario: class MyClass { Producer p; Consumer c; public static void
Given the following POCO classes: public class Certification { public int Id { get;
I am a NHibernate newbie. Suppose you have a Customer class like this public
I have this scenario where I need data integrity in the physical database. For
we have this scenario: A server which contains needed data and client component which
I have this typical scenario. I have a smartclient application built on .net 2.0
This is a question for a WSS/SharePoint guru. Consider this scenario: I have an

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.