public void Add(Answer answer)
 {
     if (Answers == null)
     {
         Answers = new List<Answer>();
     }
     answer.Question = this;
     Answers.Add(answer);
 }
 /// <summary>
 /// Сохраняет изменения по ответу
 /// </summary>
 /// <param name="answer">ссылка на ответ</param>
 public void SaveOrUpdate(SQLiteConnection conn, Answer answer)
 {
     if (answer.ID == 0)
     {
         int ID = indexService.NextID(Answer.TABLE_NAME);
         string sql = string.Format(insertIntoSql, Answer.TABLE_NAME, ID, answer.Value,
             Convert.ToInt32(answer.Right), answer.Question.ID);
         ExecuteNonQuery(conn, sql);
         answer.ID = ID;
     }
     else
     {
         using (SQLiteCommand insertSQL = new SQLiteCommand("UPDATE ANSWERS SET Value = @Value, Right = @Right, Question_ID = @Question_ID WHERE ID = @ID", conn))
         {
             insertSQL.Parameters.AddWithValue("@Value", answer.Value);
             insertSQL.Parameters.AddWithValue("@Right", answer.Right);
             insertSQL.Parameters.AddWithValue("@Question_ID", answer.Question.ID);
             insertSQL.Parameters.AddWithValue("@ID", answer.ID);
             insertSQL.ExecuteNonQuery();
         }
     }
 }
 /// <summary>
 /// Преобразует в ответ
 /// </summary>
 /// <param name="reader">ответ от запроса</param>
 /// <returns>ответ</returns>
 private Answer ToAnswer(SQLiteDataReader reader)
 {
     Answer answer = new Answer();
     answer.ID = Convert.ToInt32(reader["ID"]);
     answer.Value = Convert.ToString(reader["Value"]);
     answer.Right = Convert.ToBoolean(reader["Right"]);
     answer.Question = new Question(Convert.ToInt32(reader["Question_ID"]));
     return answer;
 }