本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.SetIsolationLevel方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.SetIsolationLevel方法的具体用法?C# CUBRIDConnection.SetIsolationLevel怎么用?C# CUBRIDConnection.SetIsolationLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUBRID.Data.CUBRIDClient.CUBRIDConnection
的用法示例。
在下文中一共展示了CUBRIDConnection.SetIsolationLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: conn_setIsolationLevel
public void conn_setIsolationLevel()
{
string conn_string = "server=test-db-server;database=demodb;port=33000;user=dba;password=";
CUBRIDConnection conn = new CUBRIDConnection();
conn.ConnectionString = conn_string;
conn.Open();
CUBRIDCommand cmd = new CUBRIDCommand();
cmd.Connection = conn;
cmd.CommandText = "drop table if exists test_isolation";
cmd.ExecuteNonQuery();
// open another session
CUBRIDConnection conn2 = new CUBRIDConnection();
conn2.ConnectionString = conn_string;
conn2.Open();
CUBRIDCommand cmd2 = new CUBRIDCommand();
cmd2.Connection = conn2;
// set up the isolation level to
conn.SetAutoCommit(false);
conn.SetIsolationLevel(CUBRIDIsolationLevel.TRAN_REP_CLASS_COMMIT_INSTANCE);
cmd.CommandText = "create table test_isolation(a int)";
cmd.ExecuteNonQuery();
conn.Commit();
conn.Close();
}
示例2: CUBRIDTransaction
/// <summary>
/// Initializes a new instance of the <see cref="CUBRIDTransaction" /> class.
/// </summary>
/// <param name="conn"> The connection. </param>
/// <param name="isolationLevel"> The isolation level. </param>
public CUBRIDTransaction(CUBRIDConnection conn, CUBRIDIsolationLevel isolationLevel)
{
if (isolationLevel == CUBRIDIsolationLevel.TRAN_UNKNOWN_ISOLATION)
throw new ArgumentException(Utils.GetStr(MsgId.UnknownIsolationLevelNotSupported));
this.conn = conn;
conn.IsolationLevel = isolationLevel;
conn.SetIsolationLevel(isolationLevel);
open = true;
}
示例3: 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);
}
}