【发布时间】:2016-06-09 14:41:37
【问题描述】:
我有两个类 Employee 和 Territory:
public class Territory
{
public string TerritoryID { get; set; }
public string TerritoryDescription { get; set; }
public IEnumerable<Employee> Employees { get; set; }
}
我正在尝试使用 LINQ 按 TerritoryID 提取员工并获得异常:
IEnumerable<Employee> empList = context.Territories
.Where(x => x.TerritoryID == territoryID)
.Select(y => y.Employees)
.ToList();
例外是:
无法将 System.Collections.Generic.List
> 类型隐式转换为 System.Collections.Generic.IEnumerable 。显式 转换存在。
【问题讨论】:
标签: c# asp.net-mvc entity-framework linq