public void SaveQuiz(Quiz quiz) { using (var ctx = new QuizBuilderEntities()) { ctx.AddToQuizzes(quiz); ctx.SaveChanges(); } }
public void UpdateQuiz(Quiz quiz) { using (var ctx = new QuizBuilderEntities()) { ctx.Attach(quiz); var stateEntry = ctx.ObjectStateManager.GetObjectStateEntry(quiz); foreach (var propertyName in stateEntry.CurrentValues .DataRecordInfo.FieldMetadata .Select(fm => fm.FieldType.Name)) { stateEntry.SetModifiedProperty(propertyName); } ctx.SaveChanges(); } }
/// <summary> /// Deprecated Method for adding a new object to the Quizzes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToQuizzes(Quiz quiz) { base.AddObject("Quizzes", quiz); }
/// <summary> /// Create a new Quiz object. /// </summary> /// <param name="quizID">Initial value of the QuizID property.</param> /// <param name="quizName">Initial value of the QuizName property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="description">Initial value of the Description property.</param> public static Quiz CreateQuiz(global::System.Int32 quizID, global::System.String quizName, global::System.String title, global::System.String description) { Quiz quiz = new Quiz(); quiz.QuizID = quizID; quiz.QuizName = quizName; quiz.Title = title; quiz.Description = description; return quiz; }