我透過 Postman軟體測試更新多筆資料,偵錯時發現傳進來的值都是空的,請問有什麼方式可以一次更改多筆資料,謝謝各位大神。
[HttpPut("Signal_Updata")]
public async Task< IActionResult > Signal_Updata(List< thieanyear > thieanyears)
{
try
{
// 逐筆把資料庫資料修改
foreach (var itme in thieanyears)
{
var Light = _PDB.thieanyear.Where(a => a.oid == itme.oid).FirstOrDefault();
if (Light != null)
{
Light.year = thieanyears.year;
Light.well_name = thieanyears.well_name;
Light.eater_level = itme.eater_level;
}
await _PDB.SaveChangesAsync();
}
ViewData.Add("ResultMessage", "資料編輯成功");
return Json(new { data = "成功" });
}
catch (DbUpdateConcurrencyException)
{
throw;
}
}
thieanyears[i].year 你的i在哪裏?