Hello! There is a web application with a base of students (id, name, age, amount of points) I want to sample 5 students from the base with the highest points and save to a txt file. This is a sample of 5 students for presentation.
StudentContext db = new StudentContext(); public ActionResult ShowTopFive () { var allStudents = db.Students.OrderByDescending(s => s.SumNote).Take(5); return PartialView(allStudents); }
Student class such
public class Student { public int StudentId { get; set; } public string Name { get; set; } public int Age { get; set; } public string Phone { get; set; } public int FirstNote { get; set; } public int SecondNote { get; set; } public int ThirdNote { get; set; } public int SumNote { get; set; } }
How can I save data for the 5 best students in the Name, SumNote format?