Dapper学习笔记(4)-事务
2015-09-02 12:36
393 查看
Dapper中对事务的处理也非常简单,如下代码所示:
private void DapperTransaction() { using (IDbConnection con = OpenConnection()) { IDbTransaction tran = con.BeginTransaction(); try { string query = "update T_Role set RoleName='开发主管' where RoleId=4";//更新一条记录 con.Execute(query, null, tran, null, null); //throw new Exception(); query = "delete from T_Role where RoleId=8";//删除一条记录 con.Execute(query, null, tran, null, null); tran.Commit(); } catch (Exception ex) { tran.Rollback(); } } }
相关文章推荐
- Android开发中退出程序几种方法
- swift类构造过程解读
- iOS---开发实用传感器
- 微信自动回复代码
- android开发软键盘遮挡登陆按钮
- 微信开发验证代码
- Swift2学习笔记(2)
- Unity5内部渲染的优化1:介绍
- iOS开发路线简述
- iOS开发之检测设备锁屏
- Android (简介) TextWatcher监控EditText 升级方案
- 苹果开发 笔记(70)常用的字符串操作
- UIWebView 的使用
- iOS进阶路线以及进阶书籍
- iOS 多线程与GCD
- Application windows are expected to have a root view controller at the end of application launch
- android视频缓冲进度条SeekBar有断断续续的间断效果
- iOS开发过程中的疑问
- 【Cocos2dx】中文乱码问题
- Android中ListView.getCount()与ListView.getChildCount()区别和OnScrollListener()各个参数的区别