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?

  • 2
    I have long noticed a pattern: most people who ask a question with an asp.net (mvc) tag do not indicate a programming language (c #, vb.net, f #, etc). What is the reason? If the language is really not important to you, write it directly. And so, many follow precisely the language questions, so by pointing it out, you will get more chances for an answer. - Alexander Petrov
  • I did not understand: judging by the asp.net mvc tag, do you want to receive data on the client and save it to a file? Or on the server it is necessary to rewrite from a DB to a file directly in the controller? - Alexander Petrov
  • So that by pressing a key from the database, data was selected and offered to save in a file - Michael Blala 7:33 pm
  • maybe it would be better to first display the data on the client, and fasten the button "save to file" ?? - Vitaliy Shebanits

0