从对象列表中提取Object属性列表

时间:2013-01-30 12:14:48

标签: c#-4.0 linq-to-entities generic-list

如果我有学生对象列表

var List<Student> = new List<Student>();

这是学生对象数据(ID,姓名)

如何仅使用Linq To Entities

提取学生ID列表

请咨询,

1 个答案:

答案 0 :(得分:3)

只需使用Enumerable.Select

List<int> studentIDs = students.Select(s => s.ID)
                               .ToList();

(虽然我不确定它与linq-to-entities的关系如何)

相关问题