Table Student
id int primary key
name nchar(10)
class_id int FOREIGN KEY to class'id
Table Class
id int primary Key
name nchar(10)
Тестовая база на ядре .net 3, ядре платформы сущностей, sql 2012, исключение "NavigationExpandingExpressionVisitor".
var query = _context.TestClass.GroupJoin(_context.TestStudent,
cla = > cla.Id,
stu = > stu.ClassId, (cla, stuCollection) = > new {
className = cla.Name,
studentsNames = stuCollection.Select(s = > s.Name)
}
);
foreach(var arr in query) {
Console.WriteLine("Class {0} Has {1} Students", arr.className, arr.studentsNames.Count());
}