I have 3 tables (teams, managers, managers_teams). It is a many to many relationship. I want to return all teams whether a manager has been assigned to the team or not. I have this for the time being and it does not work. I followed this guide but I think I am missing something.
from t in teams
join mt in managers_teams on t.id equals mt.team_id into grp_t_mt
join m in managers on mt.manager_id equals m.id // stuck here. I tried many things here
from mt in grp_t_mt.DefaultIfEmpty()
select new tvVM
{
id = t.id,
name = t.teamname,
manager = m.name
}
- Table Teams [id, teamname]
- Table Managers [id, name]
- Table managers_teams [id, team_id, manager_id]
I want to get the id, teamname from table team with the name from table managers even if records do not match.
The solution LEFT OUTER JOIN does not work for me. I get
Object reference not set to an instance of an object.