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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:43:50+00:00 2026-05-13T11:43:50+00:00

So my situation is that I have a linq-to-sql model that does not allow

  • 0

So my situation is that I have a linq-to-sql model that does not allow dates to be null in one of my tables. This is intended, because the database does not allow nulls in that field. My problem, is that when I try to write a Linq query with this model, I cannot do a left join with that table anymore because the date is not a ‘nullable’ field and so I can’t compare it to “Nothing”.

Example:
There is a Movie table, {ID,MovieTitle}, and a Showings table, {ID,MovieID,ShowingTime,Location}

Now I am trying to write a statement that will return all those movies that have no showings. In T.SQL this would look like:

Select m.*
From Movies m Left Join Showings s On m.ID = s.MovieID
Where s.ShowingTime is Null

Now in this situation I could test for Null on the ‘Location’ field but this is not what I have in reality (just a simplified example). All I have are non-null dates.

I am trying to write in Linq:

From m In dbContext.Movies _
Group Join s In Showings on m.ID Equals s.MovieID into MovieShowings = Group _
From ms In MovieShowings.DefaultIfEmpty _
Where ms.ShowingTime is Nothing _
Select ms

However I am getting an error saying

‘Is’ operator does not accept operands of type ‘Date’. Operands must be reference or nullable types.

Is there any way around this? The model is correct, there should never be a null in the Showings:ShowTime table. But if you do a left join, and there are no show times for a particular movie, then ShowTime SHOULD be Nothing for that movie…

Thanks everyone for your help.

  • 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-13T11:43:50+00:00Added an answer on May 13, 2026 at 11:43 am

    Using a left join isn’t really helping you here. Since there can never be any results in the right-hand table, you might as well just retrieve the left-hand table and only the left. This is a simple “not in” / “not exists” query:

    From m in dbContext.Movies _
    Where Not dbContext.Showings.Any(Function(s) s.MovieID = m.MovieID) _
    Select m
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation that I have not found an answer to when looking
I've got a situation where I need to have my LINQ to Entities query
I am using Ruby on Rails and have a situation that I am wondering
Here is my situation: User A must monitor the results of an sql query
I have just started evaluating whether or not I should be using OData influenced
I've read multiple sources that say Gridview's do not persist the Gridview.DataSource property on
I've got a situation which I want to fetch data from a database, and
Let's say I have the following code in WPF application: try { // NorthwindDataContext
I have an application with allows for a certain entity to be searched upon
I have an issue when I try to use datagrid.items.add() to add items from

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.