我有一张Employee桌子和一张Office桌子.这些通过EmployeeOffices表格以多对多的关系加入.
我想获得一个特定员工(CurrentEmployee)与之关联的所有办公室的列表.
我以为我可以这样做:
foreach (var office in CurrentEmployee.EmployeeOffices.SelectMany(eo => eo.Office))
;
Run Code Online (Sandbox Code Playgroud)
但这给了我错误:
用于方法"System.Linq.Enumerable.SelectMany(System.Collections.Generic.IEnumerable,System.Func>)"类型参数不能从使用推断.尝试显式指定类型参数.
我知道我可以添加类型参数.但Intellisense认识到它eo.Office属于Office类型.那么为什么编译器不清楚这一点呢?