Is it possible to commit/rollback SqlTransaction in asynchronous?

前端 未结 3 1055
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-17 17:36

I\'m trying to commit/rollback SqlTransaction in asynchronous. But it look like asynchronous is not supported. Is there any way to make it asynchronous without

3条回答
  •  太阳男子
    2021-01-17 18:21

    With .Net Core 3.0, it is now theoretically doable to commit or rollback asynchronously a transaction, with any transaction deriving from DbTransaction. So with SqlTransaction too.

    See .Net Core issue #35012. (docs.microsoft.com documentation is currently lagging on this.)

    But more important for your concern, so does lag SqlTransaction underlying implementation: you can call async methods on it, but currently as far as I can see in the source code, they are still delegating to their sync counterparts through DbTransaction default implementation. And this is the case also with Microsoft.Data.SqlClient (no async overrides).

    So you can get your code ready to commit or rollback asynchronously with .Net Core 3.0, but you will have to wait a bit more to get them actually async.

提交回复
热议问题