下面粘贴的是我在连接中收到错误的查询。
from c in Corporates.Where (a => a.EIN_NBR == "00-0000000")
join ep in EmployeePositions.Where (b => ((int)(b.EMPStartDate.Value.AddDays(28) - DateTime.Now.Date.AddDays(1)).Days) < 0)
on c.ParentCorporateId equals ep.CorporateId
join ee in EmployeeEvaluations.Where(e => e.TargetGroupId != null) on ep.EmployeeId equals ee.EmployeeId
join ees in EmployeeEvaluationStatuses on ee.EvaluationStatusId equals ees.Id
join v in Vouchers.Where(b => b.SentDate == null)
on new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, v.EmployeeEvaluationId }
//在ep.EmployeeId上等于v.EmployeeId&amp;&amp; ee.Id等于v.EmployeeEvaluationId
group ep by ep.CorporateId into g
select new
{
EmployeesMissingDocuments = g.Count()
,Description = "Expired"
}
我收到以下错误“无法执行文本选择:CS1941连接子句中某个表达式的类型不正确。在”加入“调用中类型推断失败。” 在
join v in Vouchers.Where(b => b.SentDate == null)
on new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, v.EmployeeEvaluationId }
答案 0 :(得分:4)
您使用匿名类型加入多个字段。匿名类型在两端应该是相同的,为此,属性名称(和类型!)应该是相同的。在你的情况下,他们不是:
new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, v.EmployeeEvaluationId }
要修复,请使用相同的名称:
new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, Id = v.EmployeeEvaluationId }