protected override void Dispose(bool disposing) { if (context != null) { context.Dispose(); context = null; } base.Dispose(disposing); }
public void A() { using (var context = new ExamContext()) { Question q = new Question(); q.Type = QuestionType.SingleClause; q.Text = "Question text"; q.Answers.Add(new Answer() { Text = "Correct", Score = new Score() { Points = 10 } }); q.Answers.Add(new Answer() { Text = "Wrong1" }); q.Answers.Add(new Answer() { Text = "Wrong2" }); context.Questions.Add(q); context.SaveChanges(); } }
public QuestionsController() { context = new ExamContext(); }