Hi, I've an update statement to update a column in the database. However, after I update the value, when I try to retrieve the data, its returning an old value.
public override async Task Retrieve (UserTable user)
query = "UPDATE users SET address1 = 'Mumbai' WHERE user_id = @user_id"
var sql = oVal.Db().OpenReader(query);
Console.WriteLine(user.address1);
How to get the current value after the data is being updated in the database?
Thank you in advance.
Sachin SinghPosted Feb 8, 2022, 3:51 PM
As AkPosted Feb 8, 2022, 3:24 PM
Sachin SinghPosted Feb 8, 2022, 2:53 PM
It depends on how are you retrieving the value. If you have another method to retrieve the records by userId then after updating the record simply call that method.
If you don't have any method, then your update statement should return the updated column value as output column or the complete row.
please explain what are you doing in this line. What is user and how do you get this data?
user.address1 // This is just your parameter so you are getting old value.
until you don't retrieve the value you won't get it. This is not Entity Framework where you get updated value after SaveChanges().