本文整理汇总了C#中IsolationLevel.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IsolationLevel.ToString方法的具体用法?C# IsolationLevel.ToString怎么用?C# IsolationLevel.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IsolationLevel
的用法示例。
在下文中一共展示了IsolationLevel.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NotSupportedIsolationLevel
static internal ArgumentOutOfRangeException NotSupportedIsolationLevel(IsolationLevel value) {
#if DEBUG
switch(value) {
case IsolationLevel.Unspecified:
case IsolationLevel.ReadUncommitted:
case IsolationLevel.ReadCommitted:
case IsolationLevel.RepeatableRead:
case IsolationLevel.Serializable:
case IsolationLevel.Snapshot:
Debug.Assert(false, "valid IsolationLevel " + value.ToString());
break;
case IsolationLevel.Chaos:
break;
default:
Debug.Assert(false, "invalid IsolationLevel " + value.ToString());
break;
}
#endif
return ODBC.NotSupportedEnumerationValue(typeof(IsolationLevel), (int)value);
}
示例2: Transaction
/// <summary>
/// Initialises a new instance of the <see cref="Transaction" /> class.
/// </summary>
/// <param name="sessionBase">The session that the transaction is being created for.</param>
/// <param name="isolationLevel">The isolation level.</param>
internal Transaction(ISessionBase sessionBase, IsolationLevel isolationLevel)
{
this.sessionBase = sessionBase;
if (log.IsDebug)
{
log.Debug(LogMessages.Transaction_BeginTransactionWithIsolationLevel, isolationLevel.ToString());
}
this.transaction = this.sessionBase.Connection.BeginTransaction(isolationLevel);
}
示例3: IngresTransaction
internal IngresTransaction(IngresConnection conn, IsolationLevel level)
{
switch(level)
{
case IsolationLevel.ReadUncommitted:
case IsolationLevel.ReadCommitted:
case IsolationLevel.RepeatableRead:
case IsolationLevel.Serializable:
break;
case IsolationLevel.Unspecified:
level = IsolationLevel.ReadCommitted; // default
break;
default:
throw new NotSupportedException(
"IngresTransaction(IsolationLevel."+level.ToString()+")");
}
_connection = conn;
_isolationLevel = level;
}
示例4: InvalidIsolationLevel
// IDbConnection.BeginTransaction, OleDbTransaction.Begin
static internal ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
{
#if DEBUG
switch (value)
{
case IsolationLevel.Unspecified:
case IsolationLevel.Chaos:
case IsolationLevel.ReadUncommitted:
case IsolationLevel.ReadCommitted:
case IsolationLevel.RepeatableRead:
case IsolationLevel.Serializable:
case IsolationLevel.Snapshot:
Debug.Fail("valid IsolationLevel " + value.ToString());
break;
}
#endif
return InvalidEnumerationValue(typeof(IsolationLevel), (int)value);
}
示例5: TransactionScope
/// <summary>
/// Constructor
/// </summary>
/// <param name="transactionScopeOption">An instance of the System.Transactions.TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.</param>
/// <param name="isolationLevel">the isolation level of the transaction.</param>
/// <param name="timeout">the timeout period for the transaction.</param>
public TransactionScope(TransactionScopeOption transactionScopeOption, IsolationLevel isolationLevel, TimeSpan timeout)
{
TransactionOptions options = new TransactionOptions();
options.IsolationLevel = (System.Transactions.IsolationLevel)Enum.Parse(typeof(System.Transactions.IsolationLevel), isolationLevel.ToString());
options.Timeout = timeout;
System.Transactions.TransactionScopeOption transactionScopeOptionValue = (System.Transactions.TransactionScopeOption)Enum.Parse(typeof(System.Transactions.TransactionScopeOption), transactionScopeOption.ToString());
this.transactionScope = new System.Transactions.TransactionScope(transactionScopeOptionValue, options);
TransactionScopeContext.Increase();
}
示例6: ExecuteTransaction
override internal void ExecuteTransaction(
TransactionRequest transactionRequest,
string transactionName,
IsolationLevel iso,
SqlInternalTransaction internalTransaction,
bool isDelegateControlRequest) {
if (Bid.AdvancedOn) {
Bid.Trace("<sc.SqlInternalConnectionSmi.ExecuteTransaction|ADV> %d#, transactionRequest=%ls, transactionName='%ls', isolationLevel=%ls, internalTransaction=#%d transactionId=0x%I64x.\n",
base.ObjectID,
transactionRequest.ToString(),
(null != transactionName) ? transactionName : "null",
iso.ToString(),
(null != internalTransaction) ? internalTransaction.ObjectID : 0,
(null != internalTransaction) ? internalTransaction.TransactionId : SqlInternalTransaction.NullTransactionId
);
}
switch (transactionRequest) {
case TransactionRequest.Begin:
try {
_pendingTransaction = internalTransaction; // store this for the time being.
_smiConnection.BeginTransaction(transactionName, iso, _smiEventSink);
}
finally {
_pendingTransaction = null;
}
Debug.Assert(_smiEventSink.HasMessages || null != _currentTransaction, "begin transaction without TransactionStarted event?");
break;
case TransactionRequest.Commit:
Debug.Assert(null != _currentTransaction, "commit transaction without TransactionStarted event?");
_smiConnection.CommitTransaction(_currentTransaction.TransactionId, _smiEventSink);
break;
case TransactionRequest.Promote:
Debug.Assert(null != _currentTransaction, "promote transaction without TransactionStarted event?");
PromotedDTCToken = _smiConnection.PromoteTransaction(_currentTransaction.TransactionId, _smiEventSink);
break;
case TransactionRequest.Rollback:
case TransactionRequest.IfRollback:
Debug.Assert(null != _currentTransaction, "rollback/ifrollback transaction without TransactionStarted event?");
_smiConnection.RollbackTransaction(_currentTransaction.TransactionId, transactionName, _smiEventSink);
break;
case TransactionRequest.Save:
Debug.Assert(null != _currentTransaction, "save transaction without TransactionStarted event?");
_smiConnection.CreateTransactionSavePoint(_currentTransaction.TransactionId, transactionName, _smiEventSink);
break;
default:
Debug.Assert (false, "unhandled case for TransactionRequest");
break;
}
_smiEventSink.ProcessMessagesAndThrow();
}
示例7: SetIsolationLevel
public static void SetIsolationLevel(this System.Data.SqlClient.SqlConnection connection, IsolationLevel isolationLevel)
{
if (isolationLevel == IsolationLevel.Unspecified || isolationLevel == IsolationLevel.Chaos)
{
throw new Exception(string.Format("Isolation Level '{0}' can not be set.", isolationLevel.ToString()));
}
string isolationLevelSqlName;
switch (isolationLevel)
{
case IsolationLevel.Chaos: isolationLevelSqlName = "CHAOS"; break;
case IsolationLevel.ReadCommitted: isolationLevelSqlName = "READ COMMITTED"; break;
case IsolationLevel.ReadUncommitted: isolationLevelSqlName = "READ UNCOMMITTED"; break;
case IsolationLevel.RepeatableRead: isolationLevelSqlName = "REPEATABLE READ"; break;
case IsolationLevel.Serializable: isolationLevelSqlName = "SERIALIZABLE"; break;
case IsolationLevel.Snapshot: isolationLevelSqlName = "SNAPSHOT"; break;
default: isolationLevelSqlName = "UNSPECIFIED"; break;
}
IDbCommand command = connection.CreateCommand();
command.CommandText = "SET TRANSACTION ISOLATION LEVEL " + isolationLevelSqlName;
command.ExecuteNonQuery();
}
示例8: SetIsolationLevel
public void SetIsolationLevel(string typePart, IsolationLevel expected)
{
var sql = String.Format("SET TRANSACTION ISOLATION LEVEL {0}", typePart);
var result = Compile(sql);
Assert.IsNotNull(result);
Assert.IsFalse(result.HasErrors);
Assert.AreEqual(1, result.Statements.Count);
var statement = result.Statements.ElementAt(0);
Assert.IsNotNull(statement);
Assert.IsInstanceOf<SetStatement>(statement);
var set = (SetStatement)statement;
Assert.AreEqual(TransactionSettingKeys.IsolationLevel, set.SettingName);
Assert.IsInstanceOf<SqlConstantExpression>(set.ValueExpression);
var value = (SqlConstantExpression)set.ValueExpression;
var field = value.Value;
Assert.IsInstanceOf<StringType>(field.Type);
var s = (SqlString) field.Value;
Assert.AreEqual(expected.ToString(), s.ToString());
}