How to use transactions with dapper.net?

后端 未结 5 745
夕颜
夕颜 2020-12-12 15:55

I would like to run multiple insert statements on multiple tables. I am using dapper.net. I don\'t see any way to handle transactions with dapper.net.

Please share y

5条回答
  •  -上瘾入骨i
    2020-12-12 16:48

    You should be able to use TransactionScope since Dapper runs just ADO.NET commands.

    using (var scope = new TransactionScope())
    {
       // open connection
       // insert
       // insert
       scope.Complete();
    }
    

提交回复
热议问题