views:

25

answers:

0

First of all some notes:
1. As I realize I'm asking for relatively a lot, I shall offer a (humble 50 rep) bounty ASAP, even if I'll get an answer before doing that.
2. I'm noob at this, so any direction would help.
3. I'd like only Linq2Sql designer or association properties solution, as it seems most elegant.
4. this is a follow-up question to this question where I got some directions, but couldn't really make it done.
5. I've really looked up this subject thoroughly, but couldn't understand how to do this.
6. I'm using ASP.NET MVC

And now the question:

I have three sql tables:
Questions:
ID
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 also have object model class that represent a question:

public class Question  
{
  public string Body;  
  public List<Answer> Answers;
}  

My question is how do I CRUD over my object model.
How is the mapping between the DB - associated classes - object model is done?

Here's what I started doing using the designer:
alt text

But I can't really say I understand how this works.
Is the object model class necessary, or should I lose it?
And how do I make this all as "automatic" as possible?

Thanks for your time.