I am working on a WinForms project that requires the use of Linq-To-Sql . I was able to create my DataContext using the SqlMetal tool and make some queries. But now I have a problem that I could not solve.
I am trying to make the LEFT OUTER JOIN as follows:
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 occurs while compiling the word join :
The type of one of the expressions in the join clause is invalid. Type input error in 'GroupJoin' call
I know this error is caused by a 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 execute a LEFT OUTER JOIN without this error?
p.child_ID int? since this column is marked as IS NULL in SQL .
Hope someone can help me, thanks in advance.
Dante source share