Group by with ananymous object in selector

Aug 18, 2014 at 3:59 AM
Edited Aug 18, 2014 at 4:01 AM
Hi Team,
I am new to linq js but familiar to c# linq and it looks wonderful having same funationality in javascript. Thanks to team.

I have Json data like below :
[{"AnswerId":"7820196b-8fbf-4d52-82a8-6525bcdc7bbe",
"AnswerText":"No",
 "QuestionId":"fef6467c-e4a4-4f99-8e51-221d30a8cb3a", 
 "QuestionText":"Do you have an energy balance sheet on your farm monitoring energy sources and energy consumption?",
  "QuestionType":"1"},
            
{"AnswerId":"1fbb0af5-7461-4b8e-a98e-63425d4635f9",
"AnswerText":"Yes, I have a balance sheet",
 "QuestionId":"fef6467c-e4a4-4f99-8e51-221d30a8cb3a",
 "QuestionText":"Do you have an energy balance sheet on your farm monitoring energy sources and energy consumption?",
  "QuestionType":"1"}]
I waan group all answers for question and expected output is :
{
"QuestionId":"fef6467c-e4a4-4f99-8e51-221d30a8cb3a",
 "QuestionText":"Do you have an energy balance sheet on your farm monitoring energy sources and energy consumption?",
 "QuestionType":"1",
 "Answer": [ {"AnswerId":"7820196b-8fbf-4d52-82a8-6525bcdc7bbe",
                    "AnswerText":"No"},
                  {"AnswerId":"1fbb0af5-7461-4b8e-a98e-63425d4635f9",
                   "AnswerText":"Yes, I have a balance sheet"}]
}
Please suggest , how i can get "Answer" array in select after grouping on questionid or any other way.