Hi,
While learning the CRUD I find that the Delete works only when the OnPostDeleteAsync is carrying a variablenamed id? i.e. it works like the following example:
public async Task<IActionResult> OnPostDeleteAsync(int id) { var worker = await _TempDB.Workers.FindAsync(id); if (worker != null) { _TempDB.Workers.Remove(worker); await _TempDB.SaveChangesAsync(); } return RedirectToPage(); }
But, wouldn't the same be working if the Key variable is assigned some other name like_id? e.g.
public async Task<IActionResult> OnPostDeleteAsync(int _id) { var worker = await _TempDB.Workers.FindAsync(_id); if (worker != null) { _TempDB.Workers.Remove(worker); await _TempDB.SaveChangesAsync(); } return RedirectToPage(); }
In this case the button delete only clicks, but the record from the table is not deleted?
And
What if the Key is of some other type, e.g. string instead of an int?
Any clarification / workarounds?
Thanks!