Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a join query on linq to SQL. I am getting error on join keyword that "Error 14 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'." Could you please help me? Let me know if anything else needed.

C#
var query = (from fd in dbcDefaulter.Fees_Dues
                         join sd in dbcDefaulter.Student_Details on fd.Student_ID equals sd.Student_ID
                         orderby fd.Student_ID
                         select new {  fd.Month }).ToList();
Posted
Comments
[no name] 19-Sep-14 18:23pm    
Check the types of the expressions in your join.
ZurdoDev 30-Sep-14 10:15am    
Your valuable response was the solution. Please post as such.
SandeepKushwah 20-Sep-14 6:18am    
Thats perfect. I have done the type cast and issue resolved. Thanks for your valuable response.

1 solution

The types of the properties used in the join condition need to be same in a join query.
Otherwise you can reframe your query like below.


var query = (from fd in dbcDefaulter.Fees_Dues
                         join sd in dbcDefaulter.Student_Details 
on new{
      Student_ID =(int?)fd.Student_ID
      } 
       equals 
             new{
                 Student_ID = (int?)sd.Student_ID
                }
 orderby fd.Student_ID
 select new {  fd.Month }).ToList();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900