Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void StudentStats(StudentSystemDBContext context)
- {
- var students = context.Students
- .OrderByDescending(x => x.Courses.Sum(z => z.Price))
- .ThenByDescending(c => c.Courses.Count)
- .ThenBy(s => s.Name)
- .ToList();
- Console.WriteLine($"Total students: {students.Count}");
- foreach (var student in students)
- {
- Console.WriteLine($"Name: {student.Name}, Courses: {student.Courses.Count}, Price: {student.Courses.Sum(x => x.Price)}, Average: {student.Courses.Average(a => a.Price)}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment