title: Data retrieve using entity framework issue in dotnet core
body: <p>I have a table with user answers.Assume survey contains 5 questions.Then this row contains 5 rows per user.I want to retrive it like</p>
  
  <pre><code>userEmail: 'amara@gmail.com',
                qustns: []
  </code></pre>
  
  <p>Here is the json data what I want.</p>
  
  <pre><code> uersSurveyAnswers: any = [
          {
            userEmail: 'amara@gmail.com',
            qustns: [
              {
                qNo: 1,
                ansrs: ['1']
              },
              {
                qNo: 2,
                ansrs: ['1', '0', '1', '1']
              },
              {
                qNo: 5,
                ansrs: ['2']
              },
              {
                qNo: 6,
                ansrs: ['0', '1', '1', '0']
              }
            ]
          },
          {
            userEmail: 'saman@gmail.com',
            qustns: [
              {
                qNo: 1,
                ansrs: ['3']
              },
              {
                qNo: 2,
                ansrs: ['0', '0', '1', '1']
              },
              {
                qNo: 5,
                ansrs: ['1']
              },
              {
                qNo: 6,
                ansrs: ['1', '1', '0', '0']
              }
            ]
          }]
  </code></pre>
  
  <p>But it returns like this</p>
  
  <pre><code>[
      {
          "userEmail": "amara@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "2"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "1",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "1",
                      "2",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Blue"
                  ]
              }
          ]
      },
      {
          "userEmail": "amara@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "2"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "1",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "1",
                      "2",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Blue"
                  ]
              }
          ]
      },
      {
          "userEmail": "amara@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "2"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "1",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "1",
                      "2",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Blue"
                  ]
              }
          ]
      },
      {
          "userEmail": "amara@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "2"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "1",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "1",
                      "2",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Blue"
                  ]
              }
          ]
      },
      {
          "userEmail": "saman@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "1"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "0",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "2",
                      "1",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Green"
                  ]
              }
          ]
      },
      {
          "userEmail": "saman@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "1"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "0",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "2",
                      "1",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Green"
                  ]
              }
          ]
      },
      {
          "userEmail": "saman@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "1"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "0",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "2",
                      "1",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Green"
                  ]
              }
          ]
      },
      {
          "userEmail": "saman@gmail.com",
          "qustns": [
              {
                  "qNo": 1,
                  "ansrs": [
                      "1"
                  ]
              },
              {
                  "qNo": 2,
                  "ansrs": [
                      "0",
                      "0",
                      "1",
                      "1"
                  ]
              },
              {
                  "qNo": 3,
                  "ansrs": [
                      "2",
                      "1",
                      "4",
                      "3"
                  ]
              },
              {
                  "qNo": 4,
                  "ansrs": [
                      "Green"
                  ]
              }
          ]
      }]
  </code></pre>
  
  <p>Here is my code</p>
  
  <pre><code>var qstns = await (from uans in _context.UserAnswers
                                     where uans.SurveyId == id
                                     select new UserAnswersReturnDto
                                     {
                                         UserEmail = uans.CreatedBy,
                                         Qustns = (from ans in _context.UserAnswers
                                                    where ans.CreatedBy == uans.CreatedBy 
                                                    select new UserAnswersSet
                                         {
                                             QNo = ans.QNo,
                                             Ansrs = JsonConvert.DeserializeObject&lt;JArray&gt;(string.IsNullOrEmpty(ans.Answers) ? "[]" : ans.Answers)
                                         }).ToArray() 
  
                                     }).ToListAsync();
  </code></pre>
  
  <p>How to resolve this issue.
  here is my table view screen.
  I think this issue will resolve if I add group by.But I tried it.I can't understand how to use it.please help me
  <a href="https://i.stack.imgur.com/pFxmv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pFxmv.png" alt="enter image description here"></a></p>