public void SaveChanges() { using (var context = new MillionaireContext()) { context.SaveChanges(); } }
public void Update(StatisticsEntry entry) { using (var context = new MillionaireContext()) { var question = context.Questions.Where(q => q.QuestionID == entry.QuestionID) .Include(q => q.Answers).FirstOrDefault(); int i = 0; foreach (var child in question.Answers) { context.Entry(child).Entity.TimesSelected = entry.Question.Answers[i++].TimesSelected; context.Entry(child).State = EntityState.Modified; } context.SaveChanges(); } }