我已经查看了各种Q&对于这种情况,但我的错误仍然存在。
我有以下内容:
Int32 eid = Convert.ToInt32(this.ddlPrograms.SelectedItem.Value);
var participants =
from b in _dc.WebProgramParticipants
join d in _dc.webeventaffiliations
on new { b.UserID, eid } equals new { d.userid, d.eventid }
join c in _dc.WebPersonalInfos
on b.UserID equals c.UserID
where (b.eventid == eid) select
new { b.ParticipantID, c.FirstName, c.LastName, c.Email, d.institution };
有问题的连接类型{b.UserID = int,b.eventid = int?}和等于{d.userid = int,d.eventid = int}
错误" join子句中某个表达式的类型不正确。呼叫'加入'类型推断失败。"不会消失。这是说第一个连接有类型问题,但唯一的问题是b.eventid是可以为空的,我认为包括eid变量可以工作,但它没有。
这是怎么回事?
答案 0 :(得分:0)
通过以下
解决var participants = from b in _dc.WebProgramParticipants join d in _dc.webeventaffiliations on new { UserID = b.UserID, eventid = eid } equals new { UserID = d.userid, eventid = d.eventid } join c in _dc.WebPersonalInfos on b.UserID equals c.UserID where (b.eventid == eid) select new { b.ParticipantID, c.FirstName, c.LastName, c.Email, d.institution };
确保连接条件两侧的类型具有相同的Case。 (无论如何,对于C#)