/// <summary>
 /// Create a new PollAnswer object.
 /// </summary>
 /// <param name="answerID">Initial value of the AnswerID property.</param>
 /// <param name="answer">Initial value of the Answer property.</param>
 /// <param name="votes">Initial value of the Votes property.</param>
 /// <param name="pollID">Initial value of the PollID property.</param>
 public static PollAnswer CreatePollAnswer(global::System.Int32 answerID, global::System.String answer, global::System.Int32 votes, global::System.Int32 pollID)
 {
     PollAnswer pollAnswer = new PollAnswer();
     pollAnswer.AnswerID = answerID;
     pollAnswer.Answer = answer;
     pollAnswer.Votes = votes;
     pollAnswer.PollID = pollID;
     return pollAnswer;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the PollAnswers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPollAnswers(PollAnswer pollAnswer)
 {
     base.AddObject("PollAnswers", pollAnswer);
 }
Example #3
0
 private static void CreateAnswer(string answerText, Poll newPoll)
 {
     using (PollSystemEntities context = new PollSystemEntities())
     {
         if (answerText.Length > 255)
         {
             // Special case: long text should be inserted directly
             string cmd = String.Format("INSERT INTO PollAnswers(Answer, Votes, PollID) VALUES ('{0}', {1}, {2})", answerText, 0, newPoll.PollID);
             context.ExecuteStoreCommand(cmd);
         }
         else
         {
             PollAnswer answer = new PollAnswer();
             answer.Answer = answerText;
             answer.PollID = newPoll.PollID;
             answer.Votes = 0;
             context.PollAnswers.AddObject(answer);
         }
         context.SaveChanges();
     }
 }