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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:36:56+00:00 2026-05-24T15:36:56+00:00

i’m certain that i’m missing something really obvious here. what I want to acheive

  • 0

i’m certain that i’m missing something really obvious here.
what I want to acheive is quite simple-

I’d like one query to load all Users without hydrating their Posts and Followers collections.
In another query, I do want to initialize these collections, using SubSelect.

using Fetch(..) in the second query would issue left joins, which I don’t want.
I can define those collections’ fetching strategies in the mappings like so (fluently):

.Not.LazyLoad()
.Fetch.Subselect()

which would cause the second query to run the way I want it to, but then I can’t turn off the .Not.LazyLoad() for the first query (i’ve tried .Fetch(u => u.Posts).Lazy but that doesn’t seem to do anything).

what am I missing?

  • 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-24T15:36:56+00:00Added an answer on May 24, 2026 at 3:36 pm

    I normally set lazy=true in my mappings (Ayende wrote about it) cause I prefer to control the behaviors in my code.

    Doing so your associations will be hydrated only if you require them.

    var users = session.QueryOver<User>()
        .List();
    

    Will load all your users but won’t load their posts, unless you access an element of the collection:

    var postTitle = users[0].Posts[0].Title;
    

    If you want to load some users and their posts you can simply do something like this:

    Post posts = null;
    
    var users = session.QueryOver<User>()
        .Where(x => x.Name == "Jamie")
        .Inner.JoinAlias(t => t.Posts, () => posts)
        .List();
    

    or:

    Post posts = null;
    
    var users = session.QueryOver<User>()
        .Where(x => x.Name == "Jamie")
        .Inner.JoinQueryOver(t => t.Posts, () => posts)
        .List();
    

    As you might have noticed using Fetch Eager:

    var users = session.QueryOver<User>()
        .Where(x => x.Name == "Jamie")
        .Fetch(x=>x.Posts).Eager
        .List();
    

    uses an outer join which you do not want.

    The previous two examples will have a problem you’ve mentioned in your comment.
    If you want to avoid cartesian products in your result with QueryOver you can use .TransformUsing(Transformers.DistinctRootEntity) :

    Post posts = null;
    
    var users = session.QueryOver<User>()
        .Where(x => x.Name == "Jamie")
        .Inner.JoinAlias(t => t.Posts, () => posts)
        .TransformUsing(Transformers.DistinctRootEntity)
        .List();
    

    You can find lot more information here.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string

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.