Sometimes, when i want edit line in table(db) , this line duplicates: the old line remains and new(edited) appears. But sometimes its work correct. Why? Thanks.
Angular request:
this.http.put('api/data/update', JSON.stringify(this.tabl1.filter(x => x.p1 == e.key)),
{ headers: new HttpHeaders({
"Content-Type": "application/json"})
}).subscribe(data => (console.log(data)));
Controller method:
[HttpPut]
public IActionResult update([FromBody] RaschetDoppokazR1[] obj)
{
try
{
if (obj != null)
{
db.RaschetDoppokazR1.UpdateRange(obj);
db.SaveChanges();
return Json("OK");
}
else return Json("null");
}
catch (Exception ex)
{
Console.WriteLine(ex);
return Json("Exception");
}
}
when i add new line to db , primary key there generating by the function , and if i try update line without updating my data, record will sent without primary key.