0

对于这种情况,我已经查看了各种问答,但我的错误仍然存​​在。

我有以下内容:

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 变量会起作用,但它没有。

这是怎么回事?

4

1 回答 1

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#)

于 2013-08-16T21:40:30.020 回答