In my code behind I have the following and I’m getting the error ‘Ok’ does not exist in current context. I’m trying to populate a form with textboxes.
public async Task<IActionResult> OnGetDetails(string custName)
{
var x = _context.Customer
.Join(_context.Sales,
x => x.CustId,
c => c.CustId,
(x,c) => new
{
customerName = x.Name,
address = x.Address,
sale = x.SaleDate
}).ToListArraySync();
return Ok(await q.ToListArraySync()); //causes error 'Ok' doesn't exist in current context
}
I need to prefill the form on the page out with the data. I’m able to get the data on the default OnGet(), however, I need to join two tables in this handler
2
Answers
I got it working.
I added a FK to the table and rebuilt the models and then this:
became this:
and now I can see the data from both tables on my view
You can "manually" return
OkObjectResult
orJsonResult
.ControllerBase.Ok
is just a convenience method that actually returns anOkObjectResult