Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql8.1+windows10环境下事务问题 #21

Open
xueshaoyu opened this issue Oct 23, 2023 · 0 comments
Open

mysql8.1+windows10环境下事务问题 #21

xueshaoyu opened this issue Oct 23, 2023 · 0 comments

Comments

@xueshaoyu
Copy link
Contributor

mysql8.1+windows10环境下
某个控制器内部业务为更新两个表AB,外层方法更新A表,内层方法为异步更新B表,异步方法里面,更新了B表后,会导致外层事务的Tanscation失效。
public async Task MethodA()
{
using (var tran = Log.Meta.CreateTrans())//表A事务开始
{
await MethodB();//更新表B
tran .Commit();//提交报事务未开始异常。
}
}
改为如下正常使用:
public async Task MethodA()
{
using (var tran = Log.Meta.CreateTrans())
{
MethodB().GetAwaiter().GetResult();
tran .Commit();//提交事务正常。
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant