I am looking to improve on the updating performance of data sets and seeking insights.
I have a set of 2000 rows of data in table TestResults, when new datset is made available all of the 2000 rows of data have to be updated with their respective values, in this case ratingDate and rating.
//The class
public class TestResults {
//...other properties
public int Rating {get;set}
public DateTime RatingDate {get;set;}
//...other properties
}
//updating with latest data
foreach(var item in updatedTestResults) {
context.TestResults.Where(x => x.Id == item.Id)
.ExecuteUpdate(setters => setters
.SetProperty(b => b.RatingDate, item.RatingDate )
.SetProperty(b => b.Rating, item.Rating));
}
await context.SaveChangesAsync();
My understanding is that this will generate sql update request for each entry (approximately 2000 of them)
Is there a better way, a more efficient way to do the update?