У меня есть таблица следующего характера.
+----+-----------+-----------+------+---------+------+
| Id | AccountId | ProjectId | Year | Quarter | Data |
+----+-----------+-----------+------+---------+------+
| 39 | 163 | 60 | 2019 | 2 | 0 |
| 40 | 163 | 60 | 2019 | 2 | 8 |
| 41 | 163 | 61 | 2019 | 2 | 1 |
| 42 | 163 | 61 | 2019 | 2 | 2 |
+----+-----------+-----------+------+---------+------+
Я хочу получить ProjectIds
отличного от Json, используя Entity Framework, пока мой код выглядит следующим образом.
// GET: api/Insight/163/2019/2
[HttpGet("{accid}/{year}/{qurter}")]
public async Task<IActionResult> GetSurveys([FromRoute] long accid, [FromRoute] long year, [FromRoute] long qurter)
{
//This code gives me the error.
return await _context.CustomerSatisfactionResults.Select(x=>x.ProjectId)
.Where(x => x.AccountId == accid && x.Year == year && x.Quarter == qurter).ToListAsync();
}
Когда я достигаю этой конечной точки с параметрами, /163/2019/2
Я хочу, чтобы Json отвечал как
[
"60", "61"
]
Но я получаю следующую ошибку.
Что я сделал не так?