Код: Выделить всё
public async Task Update(T updatedRecord, string operatorId) where T : BaseUser
{
var operator = await MyContext.TUsers.FirstOrDefaultAsync(u => u.userId == operatorId);
if (operator == null) throw new BusinessException("Action denied");
TUsers oldRecord = await SearchUser(updatedRecord.Id);
if (fichaAntiga == null) throw new BusinessException("User not found");
updatedRecord.UpdatedOn = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.FFF");
updatedRecord.UpdatedBy = operator.Id;
MyContext.Entry(oldRecord).CurrentValues.SetValues(updatedRecord);
await MyContext.SaveChangesAsync();
return new TUsers();
}
Код: Выделить всё
public override Task SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
{
var modifiedEntities = ChangeTracker.Entries()
.Where(p => p.State == EntityState.Modified).ToList();
foreach (var change in modifiedEntities)
{
Console.WriteLine(change.OriginalValues);
Console.WriteLine(change.CurrentValues);
}
return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
}
Подробнее здесь: https://stackoverflow.com/questions/717 ... -values-on