I\'m new to ASP.NET webapi and I can\'t find a way to return a list of objects queried by id.
This is my controller method for the GET request. I want to return all the
Just simply return it like this, you need to use one of the nice methods that ApiController now supplies.
This will return a status code of 200 along with your questions collection.
[ResponseType(typeof(List))]
public async Task GetQuestion(int questionnaireId)
{
var questions = from q in db.Questions
where q.QuestionnaireId == questionnaireId
select new Question()
{
Id = q.Id,
ImageLink = q.ImageLink,
QuestionnaireId = q.QuestionnaireId,
Text = q.Text
};
return this.Ok(questions);
}