无法更新 mssql 中的小数字段

Can't update decimal field in mssql

当我执行这个查询时:

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 

使用 SSMS 就可以了。但是,如果我尝试使用 Dapper 在 C# 中执行相同的操作,则会出现提示。

它不会更新 test_temp.aut_z3 字段。

C#代码:

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);

我也这样试过,结果是一样的。没有任何反应:

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);

知道为什么吗?

问题是我在multithreading里面调用了ExecuteAsync方法,在ExecuteAsync方法返回结果之前线程就关闭了。 我通过用 Execute 方法替换 ExecuteAsync 方法来修复它。 .Wait()getawaiter 都没有帮助。