c# - 在 linq 的 join 命令中获取左连接对象
问题描述
我有 2 个课程:StudentClass 和 SelectedLessonClass。
StudentClass{
studentId,
name,
family}
SelectedLessonClass{
studentId,
lessonId}
我需要选择课程 ID=12 的学生的信息;
我使用加入命令:
students=students.join(selectedLessons.where(sl=>sl.lessonId==12).tolist(),st=>st.studentId,sl=>sl.studentId,.....)
请指导我,我必须填写什么而不是......?
谢谢
解决方案
假设你有listStudents
,listLessons
你可以尝试这样的事情(result
是符合你标准的学生列表):
var result = from s in listStudents
join l in listLessons
on s.studentId equals l.studentId
where l.lessonId=12
select s;
推荐阅读
- postgresql - 有效地在 Postgres 数据库中提前查询最后一个数据集 x
- yaml - 如何在 yaml 中正确转义 &&
- arrays - 在 bash 中的持久存储中记录文件的名称和源路径
- python - 编写一个 python 程序,它将一个字符串作为用户的输入。输入字符串应包含字母和数字的组合
- flutter - 期望一个班级成员。:19
- phpspreadsheet - 使用 PhpSpreadsheet,如何为整个工作表(而不是整个电子表格)设置样式
- apache-flink - 如何定期将流的统计信息发送到 Flink 中的另一个流
- python - json 文件中的分组值
- amazon-web-services - VMWare 虚拟机到 AWS/Azure 的迁移
- hibernate - 使用 Hibernate Validator 进行实体验证的问题