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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:18:12+00:00 2026-05-24T13:18:12+00:00

I have the classic situation Orders/OrderLines. I wanted to fetch some orders and eagerly

  • 0

I have the classic situation Orders/OrderLines.
I wanted to fetch some orders and eagerly load the orderslines with an outer join.
I have noticed that if I use QueryOver:

var orders2 = session.QueryOver<Domain.Order>()
   .Where(x => x.Company == "HBP00").And(x => x.Number == "VI11001680")
   .Fetch(x => x.OrderLines).Eager
   .List();

I get a cartesian product.
orders2 contains 11 rows even if there’s just one order, but infact it has got 11 orderlines.
If I use Query:

var orders1 = session.Query<Domain.Order>()
    .Where(x => x.Company == "HBP00" && x.Number == "VI11001680")
    .Fetch(x => x.OrderLines)
    .ToList();

everything works properly.
The funny thing is I’ve analyzed the query and they’re identical.
Is there anything I have to know not to get a cartesian product eagerly loading a collection with QueryOver?

  • 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-24T13:18:13+00:00Added an answer on May 24, 2026 at 1:18 pm

    I’ve found a solution reading this blog.

    Apparently, you need .TransformUsing(Transformers.DistinctRootEntity) with CreateQuery, CreateCriteria or QueryOver but you do not need it with Query.

    Here’s how I fixed it:

    var orders2 = session.QueryOver<Domain.Order>()
       .Where(x => x.Company == "HBP00").And(x => x.Number == "VI11001680")
       .Fetch(x => x.OrderLines).Eager
       .TransformUsing(Transformers.DistinctRootEntity)
       .List();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a classic ASP application which inserts some values into a word file
We have a classic ASP site that is been hosted in IIS 7.5. I
NET and VB.net code behind. I have a classic ASP page that connects to
What I am trying to do is simple. I have some Classic ASP with
I have the following shortened classic ASP code that makes a SQL insert call...
This seems like a classic rails situation: I want to have a my index
I am currently in a situation where I have to make some additions to
I am facing a situation that I have problem understanding... I am writing a
We have a classic ASP page that is instantiating a .Net object through a
I have a classic asp webapp that I need to implement url re-writing in.

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.