コード例 #1
0
 public void SaveQuizAttempt(QuizAttempt quizAttempt)
 {
     using (var ctx = new QuizBuilderEntities())
     {
         ctx.AddToQuizAttempts(quizAttempt);
         ctx.SaveChanges();
     }
 }
コード例 #2
0
 public void UpdateQuizAttempt(QuizAttempt quizAttempt)
 {
     using (var ctx = new QuizBuilderEntities())
     {
         ctx.Attach(quizAttempt);
         var stateEntry = ctx.ObjectStateManager.GetObjectStateEntry(quizAttempt);
         foreach (var propertyName in stateEntry.CurrentValues
                              .DataRecordInfo.FieldMetadata
                              .Select(fm => fm.FieldType.Name))
         {
             stateEntry.SetModifiedProperty(propertyName);
         }
         ctx.SaveChanges();
     }
 }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the QuizAttempts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToQuizAttempts(QuizAttempt quizAttempt)
 {
     base.AddObject("QuizAttempts", quizAttempt);
 }
コード例 #4
0
 /// <summary>
 /// Create a new QuizAttempt object.
 /// </summary>
 /// <param name="quizAttemptID">Initial value of the QuizAttemptID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 /// <param name="quizID">Initial value of the QuizID property.</param>
 /// <param name="score">Initial value of the Score property.</param>
 /// <param name="quizDate">Initial value of the QuizDate property.</param>
 public static QuizAttempt CreateQuizAttempt(global::System.Int32 quizAttemptID, global::System.Int32 userID, global::System.Int32 quizID, global::System.Int32 score, global::System.DateTime quizDate)
 {
     QuizAttempt quizAttempt = new QuizAttempt();
     quizAttempt.QuizAttemptID = quizAttemptID;
     quizAttempt.UserID = userID;
     quizAttempt.QuizID = quizID;
     quizAttempt.Score = score;
     quizAttempt.QuizDate = quizDate;
     return quizAttempt;
 }