I'm using WebAPI in entity framework to create a new endpoint and I am having some issues. I'm trying to use a Linq Where statement to get my data, but I'm receiving the following error.
'IQueryable' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IQueryable' could be found (are you missing a using directive or an assembly reference?)
Here is my code.
[ResponseType(typeof(Vocab))]
public async Task<IHttpActionResult> GetVocabByLesson(int lessonId)
{
Vocab vocab = await db.Vocabs.Where(a => a.LessonId == lessonId);
if (vocab == null)
return NotFound();
return Ok(vocab);
}
Where
to be awaitable? And when do you ever expect the result to benull
? (Where
returns a sequence - which may be empty, but which is never null...) – Jon Skeet