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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:55:36+00:00 2026-06-11T14:55:36+00:00

I am working on a WinForms project which requires to use Linq-To-Sql . I

  • 0

I am working on a WinForms project which requires to use Linq-To-Sql. I have been able to create my DataContext using the SqlMetal tool, and make some queries. But right now I have a problem that I havent been able to solve.

I am trying to make a LEFT OUTER JOIN as following:

MyDatabase db = new MyDatabase(...);

 var query = from p in db.ParentTable
             join t in db.ChildTable on new {A = p.child_ID, B = p.OtherID}
             equals new {A = t.ID, B = t.OtherID} into j1
             from c in j1.DefaultIfEmpty()
             select new
             {
                  ...
             };

When I write this query an error is raised at compile-time in the join word:

The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to ‘GroupJoin’

I know this error is caused by the comparison between p.child_ID and t.ID since p.child_ID is int? and t.ID is int. But, How can I solve this? How can I perform the LEFT OUTER JOIN without having this error??

p.child_ID is int? since this column is marked as IS NULL in SQL.

Hope someone can help me, thanks in advance.

  • 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-06-11T14:55:37+00:00Added an answer on June 11, 2026 at 2:55 pm

    You can use GetValueOrDefault() method. It retrieves the value of the current Nullable object, or the object’s default value.

    In terms of your example :

    var query = from p in db.ParentTable
                join t in db.ChildTable on new {A = p.child_ID.GetValueOrDefault(0), B = p.OtherID}
                equals new {A = t.ID, B = t.OtherID} into j1
                from c in j1.DefaultIfEmpty()
                select new
                {
                    ...
                };
    

    If the p.child_ID become null than it will return 0. Hope this will help !!

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

Sidebar

Related Questions

I am working on a winforms application using LINQ to SQL - and am
My team working in a project using Winforms application(c#) & MSSQL 2005 as database.
I am working on a winforms application using C#. I have a dictionary with
I am working on a winforms project and i have this following code in
I'm using an ErrorProvider control in winforms project. Its working for the most part
I'm relatively new to .NET GUI programming using WinForms (the project I'm working on
I'm working on a large Winforms project for a client that is using business
I am working in a C# winforms project and I have a user control
I'm using agsXMPP in my .NET project (WinForms) I have the following Code block,
I am working on a WinForms project which feels sluggish. It is composed of

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.