Is there a way to use TransactionScope with an existing connection?

前端 未结 3 1761
别跟我提以往
别跟我提以往 2020-12-10 03:04

I have some code that works like the advised use of TransactionScope, but has an ambient connection instead of an ambient transaction.

Is there a way to use a Transa

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 03:11

    In fact, there is one way.

    connection.EnlistTransaction(Transaction.Current)
    

    It works and it doesnt promote transaction to distributed if not necessary (contrary to what documentation says)

    HTH

提交回复
热议问题