When I execute this query:
UPDATE test_temp SET
test_temp.aut_z3 = 2.99,
test_temp.slo_z3 = 0,
test_temp.ita_z3 = 0
WHERE test_temp.product_id_part_1 = 10877
AND test_temp.product_id_part_2 = 0
using SSMS it works. But if I try to do the same in C# using Dapper then noting happens.
It won't update the test_temp.aut_z3
field.
C# code:
var sqlStatement = @"
UPDATE test_temp SET
test_temp.aut_z3 = 2.99,
test_temp.slo_z3 = 0,
test_temp.ita_z3 = 0
WHERE test_temp.product_id_part_1 = 10877
AND test_temp.product_id_part_2 = 0
";
await sqlConnection.ExecuteAsync(sqlStatement, null, null, DapperHelper.CommandTimeout);
I have also tried it like this, but the result is the same. Nothing happens:
var sqlStatement = @"
UPDATE test_temp SET
test_temp.aut_z3 = @aut_z3,
test_temp.slo_z3 = @slo_z3,
test_temp.ita_z3 = @ita_z3
WHERE test_temp.product_id_part_1 = @product_id_part_1
AND test_temp.product_id_part_2 = @product_id_part_2
";
var sqlParameters = new
{
product_id_part_1 = 10877,
product_id_part_2 = 0,
aut_z3 = 2.99,
slo_z3 = 0,
ita_z3 = 0
};
await sqlConnection.ExecuteAsync(sqlStatement, sqlParameters, null, DapperHelper.CommandTimeout);
Any idea why?
The problem was that I called the ExecuteAsync
method inside multithreading
and the thread was closed before the ExecuteAsync
method returned the result.
I fixed it by replacing the ExecuteAsync
method with the Execute
method. The .Wait()
didn't help nor the getawaiter
.