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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:57:09+00:00 2026-05-25T13:57:09+00:00

The particular situation I am currently trying to get around involves a bool? referencing

  • 0

The particular situation I am currently trying to get around involves a bool? referencing a nullable bit field in the database. But the logic should apply to many different cases.

I am using Entity Framework and have an object with a bool? property. I am starting to write a lot of Linq around this particular property, but because Sql doesnt retrieve null values when bool? != true is written, I am finding I am writing queries that look like:

var Result = from f in FooList
             where f.NullableBool == false || f.NullableBool == null
             where f.Bar.Contains(SearchTerm)
             select f;

This isn’t a massive problem, but I would really like to be able to remove the “x.NullableBool == false || x.NullableBool == false” to a different place and instead call something like:

var Result = from f in FooList
             where f.IsNot && f.Bar.Contains(SearchTerm)
             select f;

I have tried adding properties and methods of types like ‘Expression < Func < Foo, bool > >’, ‘Func < Foo, bool >’ and ‘bool’ to the Foo class but Linq doesn’t seem to like them.

Any pointers greatly appreciated.

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-25T13:57:10+00:00Added an answer on May 25, 2026 at 1:57 pm

    An extension method of IQueryable should work:

    public static class QueryExtensions
    {
        public static IQueryable<Foo> WhereIsNot(this IQueryable<Foo> query)
        {
            return query.Where(f => 
                f.NullableBool == false || f.NullableBool == false);
        }
    }
    

    Then you can use it this way:

    var result = from f in FooList.WhereIsNot()
                 where f.Bar.Contains(SearchTerm)
                 select f;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a bit of a messy database situation. Our main back-office system is
I'm currently working on some performance critical code, and I have a particular situation
In this particular situation, there are 9 automated steps in a process that take
In my particular situation, I have a couple of solutions to my problem. I
I have a particular situation: a service started by a broadcast receiver starts an
I have a situation where particular elements (xs:simpleType, xs:complexType) are placed in the output
Here's the situation: On a particular branch, some changes have been merged in from
This is for simulation. In particular, I'm trying to generate natural sounding words and
Here's the situation: I'm attempting to get a collection of all types in my
I'm trying to weigh the pros and cons of a database design, and would

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.