Reputation: 10779
Pasted below is a query I am getting errors in the join.
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 }
//on ep.EmployeeId equals v.EmployeeId && ee.Id equals v.EmployeeEvaluationId
group ep by ep.CorporateId into g
select new
{
EmployeesMissingDocuments = g.Count()
,Description = "Expired"
}
I am getting the following error "Cannot execute text selection: CS1941 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'." at
join v in Vouchers.Where(b => b.SentDate == null)
on new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, v.EmployeeEvaluationId }
Upvotes: 0
Views: 65
Reputation: 101443
You use anonymous type to join on multiple fields. Anonymous type should be the same on both sides, and for that, property names (and types!) should be the same. In your case they are not:
new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, v.EmployeeEvaluationId }
To fix, use the same names:
new {ep.EmployeeId, ee.Id} equals new {v.EmployeeId, Id = v.EmployeeEvaluationId }
Upvotes: 4