测试linq,获取有教师名额的学校。比如学校有5个教师名额,teacher数量没超过5个,发现有空额
var query = (from teacher in _repositoryTeacher.Table group teacher.Id by teacher.SchoolId into groupResult select new { SchoolId = groupResult.Key, Count = groupResult.Count() }); var result = (from school in _repositorySchool.Table join teacher in query on school.Id equals teacher.SchoolId into schoolAndTeachers from schoolAndTeacher in schoolAndTeachers.DefaultIfEmpty() where schoolAndTeacher==null || schoolAndTeacher.Count<school.TypeCode select school).ToList();

 

相关文章:

  • 2021-11-07
  • 2022-12-23
  • 2021-05-25
  • 2021-12-10
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案