First, I would agree with Arran's comment: a query expression will be much easier to deal with. I am absolutely on board using a lambda form, where it makes sense, but combining is usually much simpler in query expressions.
Having said that, you basically need to emulate transparent identifiers . The code below is not verified, but it looks vague to me.
var query = context.Table_A .Join(context.Table_B, a => a.scored, u => u.userid, (a, u) => new { a, u }) .Join(context.Table_B, p => pascorer, u2 => u2.userid, (p, u2) => new { p, u2 }) .SelectMany(q => qpaTableC, (q, cs) => new { q, cs }) .Where(r => rqpadate >= startdate && rqpadate < enddate) .Select(q => new MSViewModel { scored= rqpuUser.name, scorer= rqu2.User.name, subject_name = r.cs.Subject.name, score = r.cs.score, categoryid = r.cs.id, }) .AsEnumerable() .GroupBy(t => t.scored) .ToList();
Basically p and q and r are transparent identifiers here. You have three of them, because you have two connections and the following from clause.
source share