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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:30:18+00:00 2026-05-11T18:30:18+00:00

If i do Session.Linq<MyClass>().Where(x => x.Id = someId).FirstOrDefault(); where MyClass has a set of

  • 0

If i do

Session.Linq<MyClass>().Where(x => x.Id = someId).FirstOrDefault();

where MyClass has a set of eager loaded child object on it, the FirstOrDefault() seems to prevent this from working by adding a TOP 1 to the SQL.

Is this just a bug (feature?) in Linq2NH (which i understand is being rewritten) or am I missing something?

Is there a preferred alternative which works properly?

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-11T18:30:18+00:00Added an answer on May 11, 2026 at 6:30 pm

    Looks like a bug, in my opinion FirstOrDefault is a pretty well defined Linq operator and it has nothing to do with eager/lazy loading, so it should not break it.

    I guess there are lots of such nuances, which cause that the library is not production ready. I suggest submitting the bug the the devs.

    Falling back to DetachedCriteria (or HQL) in this case is the only option in my opinion.

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

Sidebar

Related Questions

I have an NHibernate LINQ query like this: var maxNumber = session .Linq<Child>() .Where(c
I am getting an error in this line of code Session.Linq<Employees>() : An object
I have a nhibernate linq query that looks like this: from b in session.Query<Bookmark>()
I've this Linq query: var query = (from i in session.Query<Photo>() where i.IsApproved ==
Suppose following codes: IEnumerable<MyClass> MakeQuery() { var query = from m in session.Linq<MyClass>() select
I have a basic NHibernate.Linq query: var items = from item in session.Linq<ObjectType>() where
I have the following Nhibernate LINQ query: var query = from c in session.Query<Customer>()
Trying out Linq for NHibernate and first noticed this: var list1 = (from ut
Hi I created this Linq query var k = from account in _session.All<AccountDetail>() join
I have a code: Session[timestamp] has a byte array in it coming using LInq

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.