代码:
public void UpdateThemeInfo(int id) { //事务 using (TransactionScope ctran = new TransactionScope()) { try { Models.ThemeInfo model = Models.ThemeInfo.Find(id); if (model != null) { model.CreatDate = DateTime.Now; model.Subject = "修改测试" + id; model.Text = "修改测试内容" + id; } model.Update(); ctran.VoteCommit(); } catch (Exception) { ctran.VoteRollBack(); } } }