We have two tables: "Tasks and Tasks" (users are assigned to the task). A task has an EntityCollection called TaskUsers.
This query returns the number of tasks for the username:
model.TaskCountByAssignee = ( from t in TaskRepository.List() from tu in t.TaskUsers group tu by tu into tug select new {Count = tug.Count(), UserName = tug.Key.Username}).ToList()
This query returns:
Admin 11
LukLed 5
I want him to return:
Admin 11
LukLed 5
null 10
Some tasks have no assignment, but I still want them in my result set. Typically in SQL, this is achieved by changing join to left join . In Linq, outside of EF, I could use DefaultIfEmpty (). How can this be done in linq for objects?
c # linq linq-to-entities entity-framework
LukLed Mar 04 '10 at 3:33 2010-03-04 03:33
source share