2

I have a different answers associated with particulary QuestionID.I have to group the answers of each question.

 Question Table ---------- QuestionID QuizID QuestionText IsMultipleAnswers Answer Table -------- AnswerID QuestionID AnswerText IsCorrectAnswer 
var query = from qst in context.Questions join ans in context.Answers on qst.QuestionID equals ans.QuestionID 

What is the way to extend my query to group the answers associated with each questionID ?

2 Answers 2

3

The 101 LINQ samples page for GroupBy might help.

Sign up to request clarification or add additional context in comments.

Comments

2

Just use the group by operator:

var query = from qst in context.Questions join ans in context.Answers on qst.QuestionID equals ans.QuestionID group ans by ans.QuestionID into groups select groups; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.