GroupBy two fields,correlate another entity, Count matching rows, show row_number using Lambda
I want to count the Tickets owned by every employee, having two Entities,related by Login_ID, so I have first to get the distinct values from the first list, then count the matching rows of the second list, I also want to assign an image url to each employee so I need a row_count like variable, also the related tickets to each employee must match the Team assigned to the employee so the correlated query must consider two fields:
int index = 0;
var workload = grouplist.GroupBy(j => new { j.LOGIN_ID, j.FULL_NAME,j.TEAM_NAME})
.Where(k => k.Key.TEAM_NAME == membergroup)
.Select(i => new
{
CoreID = i.Key.LOGIN_ID,
TicketCount = tickets
.Where(k => k.Assignee_Login_ID == i.Key.LOGIN_ID && k.Assigned_Group==i.Key.TEAM_NAME)
.Count(),
Assignee = i.Key.FULL_NAME,
url = @"~\images\man_" + (1 + (index++) % 5) + ".png"
}).ToList();
I choose to use Lambda instead of Linq because of simplicity, Ill post another example using left outer join using Linq in the next one.