zoukankan      html  css  js  c++  java
  • TransactionScope使用

    public void FixProjectSorceInsert()
    {
    TransactionOptions transactionOption = new TransactionOptions();
    //设置事务隔离级别
    transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
    // 设置事务超时时间为120秒
    transactionOption.Timeout = new TimeSpan(0, 0, 120);

    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, transactionOption))
    {
    try
    {
    Insert();

    Update();

    Delete();

    // 没有错误,提交事务
    scope.Complete();
    }
    catch (Exception ex)
    {
    throw new Exception("发送信息异常,原因:" + ex.Message);
    }
    finally
    {
    //释放资源
    scope.Dispose();
    }

    }
    }

  • 相关阅读:
    hdu 1286
    hdu 1420
    hdu 2068
    hdu 1718
    hdu 1231
    hdu 1072
    HDOJ 350留念
    hdu 1898
    hdu 1593
    帮助理解git的图
  • 原文地址:https://www.cnblogs.com/fx2008/p/4193545.html
Copyright © 2011-2022 走看看