本文整理汇总了C#中IsolationLevel类的典型用法代码示例。如果您正苦于以下问题:C# IsolationLevel类的具体用法?C# IsolationLevel怎么用?C# IsolationLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IsolationLevel类属于命名空间,在下文中一共展示了IsolationLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OleDbTransaction
internal OleDbTransaction (OleDbConnection connection, int depth, IsolationLevel isolevel)
{
this.connection = connection;
gdaTransaction = libgda.gda_transaction_new (depth.ToString ());
switch (isolevel) {
case IsolationLevel.ReadCommitted :
libgda.gda_transaction_set_isolation_level (gdaTransaction,
GdaTransactionIsolation.ReadCommitted);
break;
case IsolationLevel.ReadUncommitted :
libgda.gda_transaction_set_isolation_level (gdaTransaction,
GdaTransactionIsolation.ReadUncommitted);
break;
case IsolationLevel.RepeatableRead :
libgda.gda_transaction_set_isolation_level (gdaTransaction,
GdaTransactionIsolation.RepeatableRead);
break;
case IsolationLevel.Serializable :
libgda.gda_transaction_set_isolation_level (gdaTransaction,
GdaTransactionIsolation.Serializable);
break;
}
libgda.gda_connection_begin_transaction (connection.GdaConnection, gdaTransaction);
}
示例2: SqlServerConnection
public SqlServerConnection(
SqlConnection connection,
IsolationLevel? isolationLevel,
PersistentJobQueueProviderCollection queueProviders)
: this(connection, isolationLevel, queueProviders, true)
{
}
示例3: Transaction
public static void Transaction(IsolationLevel level, Action transactional)
{
using (UnitOfWork.Start())
{
// If we are already in a transaction, don't start a new one
if (UnitOfWork.Current.IsInActiveTransaction)
{
transactional();
}
else
{
IGenericTransaction tx = UnitOfWork.Current.BeginTransaction(level);
try
{
transactional();
tx.Commit();
}
catch
{
tx.Rollback();
throw;
}
finally
{
tx.Dispose();
}
}
}
}
示例4: BeginTransaction
public IDbTransaction BeginTransaction(IsolationLevel il)
{
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, String.Format("BeginTransaction({0})", il), dur)))
{
return new DbTransactionProxy(connection.BeginTransaction(il), context);
}
}
示例5: MsmqScopeOptions
public MsmqScopeOptions(TimeSpan? requestedTimeout = null, IsolationLevel? requestedIsolationLevel = null)
{
var timeout = TransactionManager.DefaultTimeout;
var isolationLevel = IsolationLevel.ReadCommitted;
if (requestedTimeout.HasValue)
{
var maxTimeout = GetMaxTimeout();
if (requestedTimeout.Value > maxTimeout)
{
throw new ConfigurationErrorsException(
"Timeout requested is longer than the maximum value for this machine. Override using the maxTimeout setting of the system.transactions section in machine.config");
}
timeout = requestedTimeout.Value;
}
if (requestedIsolationLevel.HasValue)
{
isolationLevel = requestedIsolationLevel.Value;
}
TransactionOptions = new TransactionOptions
{
IsolationLevel = isolationLevel,
Timeout = timeout
};
}
示例6: BeginTransaction
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
{
if (factory.AlwaysReturnTransaction != null)
return factory.AlwaysReturnTransaction;
return DbConnection.BeginTransaction(isolationLevel);
}
示例7: AutoRollbackTransaction
public static void AutoRollbackTransaction(IsolationLevel level, Proc transactional, UnitOfWorkNestingOptions nestingOptions)
{
using (UnitOfWork.Start(nestingOptions))
{
// If we are already in a transaction, don't start a new one
if (UnitOfWork.Current.IsInActiveTransaction)
{
transactional();
}
else
{
RhinoTransaction tx = UnitOfWork.Current.BeginTransaction(level);
try
{
transactional();
tx.Rollback();
}
catch
{
tx.Rollback();
throw;
}
finally
{
tx.Dispose();
}
}
}
}
示例8: executeNonQuery
public Int32 executeNonQuery(MySqlCommand mySqlCommand, IsolationLevel isolationLevel)
{
using (MySqlTransaction transaccion = conexion.BeginTransaction(isolationLevel))
{
Int32 safectados = 0;
try
{
mySqlCommand.Connection = conexion;
mySqlCommand.Transaction = transaccion;
safectados = mySqlCommand.ExecuteNonQuery();
// Commit a la transacción
transaccion.Commit();
}
catch (Exception ex)
{
ex.Source += " SQL: " + mySqlCommand.CommandText.ToString();
Log.Write(MethodBase.GetCurrentMethod().Name, ex);
throw ex;
}
return safectados;
}
}
示例9: CreateSession
public static ISession CreateSession(this IDatabase database, string userName, string password, IsolationLevel isolation)
{
if (!database.Authenticate(userName, password))
throw new InvalidOperationException(String.Format("Unable to create a session for user '{0}': not authenticated.", userName));
return database.CreateSession(userName, isolation);
}
示例10: ServiceBusTransactionScope
public ServiceBusTransactionScope(string name, IsolationLevel isolationLevel, TimeSpan timeout)
{
this.name = name;
log = Log.For(this);
ignore = Transaction.Current != null;
if (ignore)
{
if (log.IsVerboseEnabled)
{
log.Verbose(string.Format(ESBResources.QueueTransactionScopeAmbient, name,
Thread.CurrentThread.ManagedThreadId));
}
return;
}
scope = new TransactionScope(TransactionScopeOption.RequiresNew,
new TransactionOptions
{
IsolationLevel = isolationLevel,
Timeout = timeout
});
if (log.IsVerboseEnabled)
{
log.Verbose(string.Format(ESBResources.QueueTransactionScopeCreated, name, isolationLevel, timeout,
Thread.CurrentThread.ManagedThreadId));
}
}
示例11: SqlTransaction
internal SqlTransaction (SqlConnection connection, IsolationLevel isolevel)
{
this.connection = connection;
this.isolationLevel = isolevel;
isOpen = true;
isRolledBack = false;
}
示例12: BeginTransaction
public void BeginTransaction(IsolationLevel level)
{
if (mConnection.State == ConnectionState.Closed)
mConnection.Open();
mTransaction = mConnection.BeginTransaction(level);
}
示例13: NpgsqlTransaction
internal NpgsqlTransaction(NpgsqlConnection conn, IsolationLevel isolationLevel)
{
Contract.Requires(conn != null);
Contract.Requires(isolationLevel != IsolationLevel.Chaos);
Connection = conn;
Connector.Transaction = this;
Connector.TransactionStatus = TransactionStatus.Pending;
switch (isolationLevel) {
case IsolationLevel.RepeatableRead:
Connector.PrependInternalMessage(PregeneratedMessage.BeginTransRepeatableRead);
break;
case IsolationLevel.Serializable:
case IsolationLevel.Snapshot:
Connector.PrependInternalMessage(PregeneratedMessage.BeginTransSerializable);
break;
case IsolationLevel.ReadUncommitted:
// PG doesn't really support ReadUncommitted, it's the same as ReadCommitted. But we still
// send as if.
Connector.PrependInternalMessage(PregeneratedMessage.BeginTransReadUncommitted);
break;
case IsolationLevel.ReadCommitted:
Connector.PrependInternalMessage(PregeneratedMessage.BeginTransReadCommitted);
break;
case IsolationLevel.Unspecified:
isolationLevel = DefaultIsolationLevel;
goto case DefaultIsolationLevel;
default:
throw PGUtil.ThrowIfReached("Isolation level not supported: " + isolationLevel);
}
_isolationLevel = isolationLevel;
}
示例14: GetUnitOfWork
public override IUnitOfWork GetUnitOfWork(IsolationLevel isolationLevel = IsolationLevel.Unspecified)
{
if ((object)this.DictionaryUnitOfWorkCallback != null)
return this.DictionaryUnitOfWorkCallback();
else
return null;
}
示例15: TestAdapterService
private TestAdapterService(IsolationLevel isolationLevelToUse, Func<IDataAccessAdapter> adapterFunc)
{
_AdapterFunc = adapterFunc;
_IsolationLevel = isolationLevelToUse;
ResetActionsOnceCalled = true;
}