THE TYPE OF ONE OF THE EXPRESSIONS IN THE JOIN CLAUSE IS INCORRECT. TYPE INFERENCE FAILED

Ashish Pandey

Total Post:128

Points:898
Posted by  Ashish Pandey
.NET  C#  LINQ 
C#
 1335  View(s)
Ratings:
Rate this:

I’m trying to join two tables using 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'."

var query = (from es in Company.Employee_Salary

                         join ed in Company.Employee_Details on es.Employee_ID equals es.Student_ID

                         orderby es.Employee_ID

                         select new {  es.Month }).ToList();

  1. Anchal Kesharwani

    Post:10

    Points:70
    Re: The type of one of the expressions in the join clause is incorrect. Type inference failed

    hi ashish,


    I hope that this code help you.

    What if you cast the id that is an int to a string before comparing?

    var query = (from es in Company.Employee_Salary

                             join ed in Company.Employee_Details on es.Employee_ID.ToString() equals es.Student_ID

                             orderby es.Employee_ID

                             select new {  es.Month }).ToList();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!