Im playing around with RavenDb and am building some kind of quiz. There are different types of question: - Multiple choice (A, B, C or D?) - Date (On what date did...?) - Number (How many...?)
What I did is create a base class Question, with a property Question, which contains the question as a string and a list of Answers, the users have given.
public class Question
{
public string Question { get; set; }
public List<Answer> Answers { get; set; }
}
Then I created multiple subclasses, which inherit from Question.
For example, NumberQuestion contains the properties MinimumValue and MaximumValue, since this differences per question.
I want users to give an answer, and save that answer to the database. THe problem is, that the answer can be different types, like a DateTime, float or integer(multiple choice). My question is, what is the best way to save the Answer in a RavenDb?
This is what I'm currently doing:
public class Answer
{
public User User { get; set; }
public string AnswerString { get; set; }
public string AnswerType { get; set; }
}
What I do here, is save the answer as a string and save the type (DateTime, float etc) also, so I can parse it later.
It works, but I don't like it very much. There must be another, better way.
"Like it very much"..? - MethodMan