【发布时间】:2013-09-03 23:14:40
【问题描述】:
我有一个Employee 表和一个Office 表。它们通过EmployeeOffices 表以多对多关系连接。
我想获取与特定员工 (CurrentEmployee) 关联的所有办公室的列表。
我想我可以这样做:
foreach (var office in CurrentEmployee.EmployeeOffices.SelectMany(eo => eo.Office))
;
但这给了我错误:
无法从用法中推断方法“System.Linq.Enumerable.SelectMany(System.Collections.Generic.IEnumerable, System.Func>)”的类型参数。尝试明确指定类型参数。
我知道我可以添加类型参数。但 Intellisense 识别出eo.Office 属于 Office 类型。那么为什么编译器不清楚呢?
【问题讨论】:
标签: c# entity-framework linq