Error 25 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'
I had a scenario where i needed to fetch Result Data from multiple tables on basis of some condition by applying joins between the tables using Entity Framework. I was using Linq queries as in EF linq query is faster than the normal string queries and stored procedures, but i was getting the exception.
Here is the query which i wrote:
I made the object of my EntitiesClass generated by EDM:
which i know was wrong and on this query i was getting this exception:
The mistake i was making was pretty was pretty simple in this scenario i dont need the join because i was only selecting data from LEVEL_COURSE table which can be achieved by simple where clause in the current scenario like this:
This solved my problem and the exception that i was getting was due to column names were same. My PACKAGES table and LEVEL_COURSE table both have column named course_ID which were of same datat type as well so it was confusing compiler to take which one, but at last i got working thing as i needed.
Here is the query which i wrote:
I made the object of my EntitiesClass generated by EDM:
OLSContainer ols = new OLSContainer(); var reSet = from l in ols.LEVEL_COURSE join lp in ols.PACKAGES on new { l.course_ID, l.levelID } equals new { lp.course_ID, lp.level_ID } select l;
Error 25 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'
The mistake i was making was pretty was pretty simple in this scenario i dont need the join because i was only selecting data from LEVEL_COURSE table which can be achieved by simple where clause in the current scenario like this:
OLSContainer ols = new OLSContainer(); var reSet = (from l in ols.LEVEL_COURSE from p in ols.PACKAGES where l.course_ID == p.course_ID && l.levelID == p.level_ID && l.course_ID==courseID select new { l.levelID, l.levelName }).Distinct();
This solved my problem and the exception that i was getting was due to column names were same. My PACKAGES table and LEVEL_COURSE table both have column named course_ID which were of same datat type as well so it was confusing compiler to take which one, but at last i got working thing as i needed.