Ok,
here is how I update a single object:
public void UpdateRespondent(Respondent changed)
{
var respondent = db.Respondents.FirstOrDefault(r => r.RespondentId == changed.RespondentId);
db.Respondents.ApplyCurrentValues(changed);
db.SaveChanges();
}
This will invoke 1 select and 1 update (if something changed).
Now, if I have a List<Respondent> with hundreds of them, how do I do that, call UpdateRespondent(changed) on each one in a loop? That will result in hundreds * 2 sql statements.
Or is there a more efficient way to do this?
Thanks.
EF does not support batch updates. You can look into using EntityFramework Extended Library — I’ve seen others who’ve had success using it:
https://github.com/loresoft/EntityFramework.Extended
Code sniplet from above link:
Alternatively, you could use straight ADO.Net and call a stored proceudre.
Good luck.