我正在使用嵌套选择,似乎我正在做的事情不正确!
我正在尝试检索所有Topics
项目。
public class Employee
{
public int Id{ get; set; }
//....other fields....
//......
public IList<Topics> Interest { get; set; }
}
public class Topics
{
public int Id { get; set; } ;
public string Name { get; set; } ;
//other fields
}
employeeItems = (from _emp in employees
select new Employee
{
EmpId = _emp.mediaId,
EmpName = _emp.mediaType,
......................
Interest = (from _emp1 in employees.Interest //has few rows
select new Topic
{
Id = _emp1.Topics[0].Id, //.<int>("id"), <<<ERROR
Name = _emp1.Topics[0].Name //["name"] <<<ERROR
}).ToList()
}).ToList();
}