我有一个返回 StudentID 的控制器操作。
[HttpPost()]
public ActionResult DisplayStudents()
{
StudentDataContext db = new StudentDataContext ();
var StudentID = (from s in db.vwStudents.Where(s => s.StudentID != null)
group s by s.StudentID into g
select g.Key).ToList();
return Json(new {StudentID});
}
我也想从同一视图返回“StudentName”,但解析最终结果并返回“StudentID - StudentName”,例如“JD11212 - John Deat”
有没有一种方法可以将两列“StudentID”和“StudentName”组合在一起并返回?