I have an Employee
table and an Office
table. These are joined in a many-to-many relationship via the EmployeeOffices
table.
I'd like to get a list of all the offices a particular employee (CurrentEmployee
) is associated with.
I thought I could do something like this:
foreach (var office in CurrentEmployee.EmployeeOffices.SelectMany(eo => eo.Office))
;
But this gives me the error:
The type arguments for method 'System.Linq.Enumerable.SelectMany(System.Collections.Generic.IEnumerable, System.Func>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I understand I could add type arguments. But Intellisense recognizes that eo.Office
is of type Office. So why isn't this clear to the compiler?