C#Linq to SQL:join子句中某个表达式的类型不正确。类型推断失败 [英] C# Linq to SQL: The type of one of the expressions in the join clause is incorrect. Type inference failed

查看:443
本文介绍了C#Linq to SQL:join子句中某个表达式的类型不正确。类型推断失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linq上写一个连接查询到SQL。 我在连接关键字 上遇到错误错误14连接子句中某个表达式的类型不正确。在调用'时类型推断失败'加入'。你能帮我吗?如果还有其他需要,请告诉我。



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.

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();

推荐答案

连接条件中使用的属性类型在连接查询中需要相同。

否则你可以重新调整您的查询,如下所示。





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();


这篇关于C#Linq to SQL:join子句中某个表达式的类型不正确。类型推断失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆