我正在制作一个从数据库中获取数据的列表,一个教师可以教一个班级的许多学生我想要只显示该课程一次,而不是在下拉列表中显示多次,如下所示,
下拉列表代码
@Html.DropDownListFor(m => m.subject, new SelectList(ViewBag.subject, "CLassSubjectId", "objsub"), "Select", new { @class = "form-control" })
Linq查询:
(from t in db.TeacherEnroll
from s in db.EnrollInClass.Where(
s => s.BranchClassesId == t.BranchClassesId &&
s.ClassSubject.SubjectId == t.SubjectId &&
t.Teacher.TeacherName.Equals(Currentuser)
)
select s);