I cannot seem to get past this error in my ASP.net Core 6 API web app.
My httpget()
// GET: api/Shippingschedules/shipname
[HttpGet("{shipname}")]
public async Task<ActionResult<Shippingschedule>> GetShippingSchedulesByShip(string shipname)
{
ActionResult<Shippingschedule> Shippingschedule = await _context.Shippingschedules.Where(
x => x.Text.Contains(shipname)).ToListAsync(); //.FirstOrDefaultAsync();
if (Shippingschedule == null)
{
return NotFound();
}
return Shippingschedule;
}
But if replace the ToListAsync() to the FirstOrDefaultAsync(), it compiles. Why?
I am trying to bring back all the records it finds, not just the first one. What am I doing wrong?
Thanks