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

  • Home
  • SEARCH
  • 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 3876478
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:23:10+00:00 2026-05-19T22:23:10+00:00

Could someone point out why this could be happening: I am using NHibernate and

  • 0

Could someone point out why this could be happening:

I am using NHibernate and the Linq provider for it.

The code that fails is listed here:

var sequence = session.Query<T>();

var wtfSequence = sequence.Where(x => true);
var okaySequence = sequence.Where(x => x.Id > 0);

Debugging shows that sequence (which is an IQueryable<T>) after this contains 2 elements, which were added to the database.

I expect the first Where statement to yield all elements from that sequence, but unfortunately it leaves 0 elements.

(WHY???)

The second Where statement, on the contrary, actually yields 2 elements as it should work.

Here are the NHibernate -> Sqlite queries for the first and second Where statements.

NHibernate: select cast(count(*) as INTEGER) as col_0_0_ from "BinaryUnitProxy_IndicatorUnitDescriptor" binaryunit0_ where @p0='true';@p0 = 'True' [Type: String (0)]

NHibernate: select cast(count(*) as INTEGER) as col_0_0_ from "BinaryUnitProxy_IndicatorUnitDescriptor" binaryunit0_ where binaryunit0_.Id>@p0;@p0 = 0 [Type: Int32 (0)]

Now, if I test the same code with my InMemoryRepository, which stores every entity in a simple list, the (x => true) works absolutelty fine.

So – why does this happen when using NHibernate? Is this a bug or I am doing something wrong?

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-19T22:23:11+00:00Added an answer on May 19, 2026 at 10:23 pm

    I don’t know NHibernate, but the problem is obvious from the generated SQL: Your database does not consider true (lowercase t) equal to True (uppercase T). In SQL server you can change this by modifying the database collation (which is a really bad idea unless you want case insensitivity for other reasons).

    My guess is this is a bug in NHibernate that you need to work around. Test t => 1 == 1 instead of t => true, which might work depending on how the NHibernate code is written.

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

Sidebar

Related Questions

Could someone point out to me which directory I should be using to work
Could someone please point out a site where I can find an algorithm to
I was just hoping that someone could point me to a reference that defines
I'm just wondering if someone could point me in the right direction here, I
I'm hoping that someone else has experienced this and can point me in the
Could someone point out the idea of overloading operator== to perform deep object comparison
Could someone please point me in the right direction with respect to OHLC data
If someone could point me to some good resources on building a stateless web
Just wondering if someone could point me in the right direction of how to
I am wondering if someone could point me in the right direction. You know

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.