I have the following code to convert the EF output to CSV file (and save it to the server side and then return it):
List<LearningActionMonitoringDTO> results = _context
.LearningActionProgressUpdates
.Include(la => la.LearningAction)
.Where(la => la.LearningActionId == actionId)
.Select(la => new LearningActionMonitoringDTO
{
Title = la.LearningAction.Title,
Progress = la.Progress,
ProgressDate = la.DateCreated.ToString("g"),
}).ToList();
using (var csv = new CsvWriter(new StreamWriter("CSVfiles/Actors.csv")))
{
csv.WriteRecords(results);
}
FileInfo f = new FileInfo("CSVfiles/Actors.csv");
return f;
I wonder if I could return the results in CSV format without first saving it to the server. I need the data in CSV file to feed into a React component for creating some charts. Any help?
text/csv.