当前位置: 首页>>代码示例>>C#>>正文


C# CUBRIDConnection.GetIsolationLevel方法代码示例

本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetIsolationLevel方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.GetIsolationLevel方法的具体用法?C# CUBRIDConnection.GetIsolationLevel怎么用?C# CUBRIDConnection.GetIsolationLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUBRID.Data.CUBRIDClient.CUBRIDConnection的用法示例。


在下文中一共展示了CUBRIDConnection.GetIsolationLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_IsolationLevel

    /// <summary>
    /// Test CUBRID Isolation Levels
    /// </summary>
    private static void Test_IsolationLevel()
    {
      string sqlTablesCount = "select count(*) from db_class";
      int tablesCount, newTableCount;

      using (CUBRIDConnection conn = new CUBRIDConnection())
      {
        conn.ConnectionString = TestCases.connString;
        conn.Open();

        TestCases.ExecuteSQL("drop table if exists isol", conn);

        conn.SetIsolationLevel(CUBRIDIsolationLevel.TRAN_REP_READ);
        Debug.Assert(conn.GetIsolationLevel() == CUBRIDIsolationLevel.TRAN_REP_READ);

        tablesCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
        TestCases.ExecuteSQL("create table isol(id int)", conn);
        newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
        //Verify table was created
        Debug.Assert(newTableCount == tablesCount + 1);

        using (CUBRIDConnection connOut = new CUBRIDConnection())
        {
          connOut.ConnectionString = TestCases.connString;
          connOut.Open();

          newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, connOut);
          //CREATE TABLE is visible from another connection
          Debug.Assert(newTableCount == tablesCount + 1);
        }

        TestCases.ExecuteSQL("drop table if exists isol", conn);
      }

      using (CUBRIDConnection conn = new CUBRIDConnection())
      {
        conn.ConnectionString = TestCases.connString;
        conn.Open();

        conn.SetIsolationLevel(CUBRIDIsolationLevel.TRAN_REP_CLASS_COMMIT_INSTANCE);
        Debug.Assert(conn.GetIsolationLevel() == CUBRIDIsolationLevel.TRAN_REP_CLASS_COMMIT_INSTANCE);

        tablesCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
        conn.BeginTransaction();
        TestCases.ExecuteSQL("create table isol(id int)", conn);
        newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
        //Verify table was created
        Debug.Assert(newTableCount == tablesCount + 1);

        using (CUBRIDConnection connOut = new CUBRIDConnection())
        {
          connOut.ConnectionString = TestCases.connString;
          connOut.Open();
          newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, connOut);
          Debug.Assert(newTableCount == tablesCount + 1);
        }

        conn.Commit();

        newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
        //Verify table was created
        Debug.Assert(newTableCount == tablesCount + 1);

        TestCases.ExecuteSQL("drop table if exists isol", conn);
        newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
        Debug.Assert(newTableCount == tablesCount);
      }
    }
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:71,代码来源:TestTransaction.cs


注:本文中的CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetIsolationLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。