How can I "translate" this SQL query to Linq Lambda Expression:
Select SC.[Description],
COUNT(C.[StatusID]) as Amount
From [StatusCandidate] SC
Left Join
(Select *
From [Candidate] AS c
Where c.RequestID = 1) AS C
ON C.StatusID = SC.StatusCandidateID
Group By SC.[Description];
I try it, But the result is not correct:
dbContext.StatusCandidates
.GroupJoin(
dbContext.Candidates.Where(u => u.RequestID == requestId),
x => x.StatusCandidateID,
y => y.StatusID,
(x, y) => new {x, y})
.GroupBy(g => new {g.x.Description})
.Select(z => new AmountStatus{
StatusName = z.Key.Description,
Amount = z.Count()
}).ToList();