I'm new to .NET Core, and I'm reading this doc https://docs.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-2.1
From there I'm practicing - I write this logic:
public async Task<ActionResult<List<DashBoar>>> GetAllAsync()
{
var x = _Repo.GetPetsAsync();
return await x.ToList();
}
But I'm getting an error.
My repo class is
public IEnumerable<DashBoar> GetPetsAsync()
{
var x = from n in _context.DashBoar
select n;
return x.ToList();
}
_Repo.GetPetsAsync()is the asynchronous operation, notx.ToList()- Camilo TerevintoToListAsync(). - LlazarToList, basically it looks like this:await (x.ToList());. Instead you could write it like this:(await x).ToList();. However, the answer provided by Asela is far more expressive. - Lasse V. Karlsen