【问题标题】:The type of one of the expressions in the join clause is incorrect [duplicate]连接子句中的表达式之一的类型不正确[重复]
【发布时间】:2014-06-19 08:35:19
【问题描述】:
public dynamic ogretimUyesiGetir2(int enstituKodu, int anabilimDaliKodu)
{
    var liste = (from p in en.OgretimUyeleri
                 join j in en.AnaBilimDallari on
                 new { p.EnstituKodu, p.AnaBilimDaliKodu }
                 equals new { EnstituKodu = j.EnstituKodu, AnaBilimDaliKodu = anabilimDaliKodu }  
                 select new 
                 {
                     p.EnstituKodu, 
                     p.AnaBilimDaliKodu, 
                     Adı = p.Adi, 
                     SoyAdı = p.Soyadi, 
                     AnaBilimDaliAdi = j.AnaBilimDaliAdi 
                 }).Where(p => p.EnstituKodu == enstituKodu &&                                 
                               p.AnaBilimDaliKodu == anabilimDaliKodu).ToList();

    return liste;
}

错误:

join 子句中的一个表达式的类型不正确。 调用“加入”时类型推断失败。

帮帮我?

【问题讨论】:

  • 使用英文设计变量和方法名。你的代码应该做什么?请添加相关的类定义

标签: c# sql linq linq-to-sql


【解决方案1】:

如果你把equals new中的代码改成下面这样

equals new { EnstituKodu = enstituKodu, AnaBilimDaliKodu = anabilimDaliKodu }  

它会起作用的。

【讨论】:

  • 问题仍然存在。 :(
  • 您是否收到相同的错误消息?
  • 是的,错误:连接子句中的表达式之一的类型不正确。
  • p.EnstituKodup.AnaBilimDaliKodu有哪些类型。它们都是整数吗?
  • 听起来很奇怪。请给我几分钟时间考虑其他任何事情,因为我认为这将是我们的问题。
猜你喜欢
  • 2014-04-14
  • 2013-10-11
  • 1970-01-01
  • 2014-11-14
  • 2012-04-25
  • 1970-01-01
  • 1970-01-01
  • 2013-01-23
相关资源
最近更新 更多