本文介紹了如何使用 dapper.net 的交易?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我想在多個(gè)表上運(yùn)行多個(gè)插入語句.我正在使用 dapper.net.我看不到任何處理 dapper.net 交易的方法.
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.
請(qǐng)分享您對(duì)如何通過 dapper.net 使用交易的想法.
Please share your ideas on how to use transactions with dapper.net.
推薦答案
這里是代碼片段:
using System.Transactions;
....
using (var transactionScope = new TransactionScope())
{
DoYourDapperWork();
transactionScope.Complete();
}
請(qǐng)注意,您需要添加對(duì) System.Transactions
程序集的引用,因?yàn)槟J(rèn)情況下不引用它.
Note that you need to add reference to System.Transactions
assembly because it is not referenced by default.
這篇關(guān)于如何使用 dapper.net 的交易?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!