我正在努力将一组结果作为List<KeyValuePair<string, string>>
返回给自动完成的插件
以下是我目前的选择声明
var fetchStudents = (from tg in dc.TEACHINGGROUPs
from sg in dc.STUGROUPs
.Where(sg => sg.GroupId == tg.GroupId)
.DefaultIfEmpty()
where sg.SetId == strSetId && tg.LecturerId == strLecturerID
from stu in dc.STUDENTRECORDs
.Where(stu => stu.StudentId == sg.StudentId)
.DefaultIfEmpty()
where stu.Name.StartsWith(name)
select new { studentName = stu.Name, studentID = stu.StudentId }).Distinct();
有没有办法选择每个结果作为List<KeyValuePair<string, string>>
,以便以正确的格式返回结果集?我有一种感觉,它正盯着我的脸,但已经盯着它几个小时了,我的大脑坏了。
(from …
select new KeyValuePair<string, string>(stu.Name, stu.StudentId))
.Distinct().ToList()