我正在尝试使用asp.net-core更改Sqlserver中的列(IsActive)
AdminController:public AdminController (ApplicationDbContext application)
{
_application = application;
}
[HttpGet]
public IActionResult ActiveUser() { return View();}
[HttpPost]
public async Task<ActionResult> ActiveUser(ApplicationUser Model)
{
ApplicationUser active = await _application.Users.FindAsync(Model.Email);
var a = active.IsActive == true;
if(active.IsActive == false) { a = Model.IsActive; }
_application.Update(active);
await _application.SaveChangesAsync();
return View();
此代码运行时没有任何错误,但实际上(IsActive)在我的数据库中没有更改。如何设置IsActive == true?
ApplicationUser active = await _application.Users.FindAsync(Model.Email);
active.IsActive = Model.IsActive;
_application.Update(active);
await _application.SaveChangesAsync();