entity framework - Get result with inner join and group by in LINQ -
i struggling group by, need list of teachers , total number of students responsible across of classes. need use linq expression
here er diagram
linq
from _teacher in teachers join _class in classes on _teacher.id equals _class.teacherid join _studentclasses in studentclasses on _class.id equals _studentclasses.classid group _studentclasses _studentclasses.studentid _grouped select new {_teacher, _class.name, _studentclasses.studentid}
you can use columns have grouped by. think can this:
from _teacher in teachers join _class in classes on _teacher.id equals _class.teacherid join _studentclasses in studentclasses on _class.id equals _studentclasses.classid group _studentclasses new { teachername=__teacher.name, classname=_class.name } _grouped select new { _grouped.key.teachername, _grouped.key.classname, stundetcount=_grouped.count() }
Comments
Post a Comment