Reputation: 797
I have this two tables from the diagrams.For every question i can have multiple answer. I want to get data by question id in json format like this:
var initialData = [
{question_id: "1", Description: "Danny", Status: "1", answers: [
{ answer_id: "1", description: "AAAAA" },
{ answer_id: "2", description: "Bbbbb" }]
}
];
I use this code
var question = db.Questions.FirstOrDefault((p) => p.questionID== id);
return this.Json(question , JsonRequestBehavior.AllowGet);
and i get this
var initialData = [
{question_id: "1", Description: "Danny", Status: "1", answers:null
}
];
Can you help my please with a solution.
Upvotes: 1
Views: 417