This is quite straightforward:
I have three tables:
Questions:
ID (PK)
Body
QuestionsAndAnswers:
QuesionID
AnswerID
Answers:
ID
Body
IsCorrect
Each has a corresponding Class:
[Table]
public class Questions
{
[Column]public int ID;
[Column]public string Body;
}
[Table]
public class QuestionsAndAnswers
{
[Column]public int QuestionID;
[Column]public int AnswerID;
}
[Table]
public class Answers
{
[Column]public int AnswerID;
[Column]public string Body;
[Column]public bool IsCorrect;
}
I need to get a question with all it's answers.
I know how to get all the questions:
private Table<Questions> questionsTable;
public SQLQuestionsRepository (string connString)
{
questionsTable=(new DataContext(connString)).GetTable<Questions>();
}
But how do I associate a specific one with it's answers?
Can I do it in one command or should I actually use linq queries? and if so, how?
Thank you.