测试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();