代码:

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();
                }
            }
        }

  

相关文章:

  • 2022-12-23
  • 2022-02-19
  • 2022-02-22
  • 2021-07-07
  • 2022-01-09
  • 2021-06-15
  • 2022-01-02
  • 2021-09-29
猜你喜欢
  • 2021-07-21
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-06-29
相关资源
相似解决方案