Here are the examples of the csharp api class System.Data.Common.DbConnection.BeginTransaction(System.Data.IsolationLevel) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
52 Examples
0
1. Example
View licenseprotected override DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) { return new GlimpseDbTransaction(InnerConnection.BeginTransaction(isolationLevel), this); }
0
2. Example
View licenseprivate IDbTransaction BeginTransaction(DbConnection connection, IsolationLevel il) { return connection.BeginTransaction(il); }
0
3. Example
View licenseprivate IDbTransaction BeginTransaction(DbConnection connection, IsolationLevel il) { return connection.BeginTransaction(il); }
0
4. Example
View licenseprivate IDbTransaction BeginTransaction(DbConnection connection, IsolationLevel il) { return connection.BeginTransaction(il); }
0
5. Example
View licenseprotected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { return _baseConnection.BeginTransaction(isolationLevel); }
0
6. Example
View licenseprotected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { var sourceTran = source.BeginTransaction(isolationLevel); //return new Transaction(sourceTran, this); return sourceTran; }
0
7. Example
View licenseprotected override DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) { return new ProfiledDbTransaction(_conn.BeginTransaction(isolationLevel), this); }
0
8. Example
View licenseprotected override DbTransaction BeginDbTransaction( IsolationLevel isolationLevel ) { return this.WrappedConnection.BeginTransaction( isolationLevel ); }
0
9. Example
View licenseprotected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { return new ProfiledDbTransaction(InnerConnection.BeginTransaction(isolationLevel), this, _profiler); }
0
10. Example
View licensepublic override DbTransaction BeginTransaction(IsolationLevel isolevel) { // Take the transaction lock before beginning the // transaction to avoid a deadlock AssertThreadOwner(); _transactionLock.OpenWriter(); return new SQLiteTransactionED<TConn>(_cn.BeginTransaction(isolevel), _transactionLock); }
0
11. Example
View licenseprotected virtual void SetTransactionIsolation( DbConnection connection, IsolationLevel? isolationLevel ) { try { if (isolationLevel != null) { // Begin a transaction to provide the proper isolation. Need to ensure // that the transaction is properly committed upon completion since we // do not have auto-commit handled. connection.BeginTransaction(isolationLevel.Value); } } catch (DbException ex) { throw new DatabaseConfigException( "Error setting transaction isolation level to " + isolationLevel + " on connection with detail " + GetDetail(ex), ex); } }
0
12. Example
View licenseprotected virtual void SetTransactionIsolation( DbConnection connection, IsolationLevel? isolationLevel ) { try { if (isolationLevel != null) { // Begin a transaction to provide the proper isolation. Need to ensure // that the transaction is properly committed upon completion since we // do not have auto-commit handled. connection.BeginTransaction(isolationLevel.Value); } } catch (DbException ex) { throw new DatabaseConfigException( "Error setting transaction isolation level to " + isolationLevel + " on connection with detail " + GetDetail(ex), ex); } }
0
13. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified) { _objectContext = ((IObjectContextAdapter)_dataContext).ObjectContext; if (_objectContext.Connection.State != ConnectionState.Open) { _objectContext.Connection.Open(); } _transaction = _objectContext.Connection.BeginTransaction(isolationLevel); }
0
14. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel) { if (_transaction != null) { throw new ApplicationException("Cannot begin a new transaction while an existing transaction is still running. " + "Please commit or rollback the existing transaction before starting a new one."); } OpenConnection(); _transaction = ((IObjectContextAdapter)_dbContext).ObjectContext.Connection.BeginTransaction(isolationLevel); }
0
15. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel) { if (_transaction != null) { throw new ApplicationException("Cannot begin a new transaction while an existing transaction is still running. " + "Please commit or rollback the existing transaction before starting a new one."); } OpenConnection(); _transaction = _objectContext.Connection.BeginTransaction(isolationLevel); }
0
16. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel) { if (_transaction != null) { throw new ApplicationException("Cannot begin a new transaction while an existing transaction is still running. " + "Please commit or rollback the existing transaction before starting a new one."); } OpenConnection(); _transaction = ((IObjectContextAdapter)_dbContext).ObjectContext.Connection.BeginTransaction(isolationLevel); }
0
17. Example
View licensepublic DbTransaction BeginTransaction(IsolationLevel il) { return GetConnection(true).BeginTransaction(il); }
0
18. Example
View licensepublic DbTransaction BeginTransaction(IsolationLevel il) { return GetConnection(true).BeginTransaction(il); }
0
19. Example
View licensepublic DbTransaction BeginTransaction(IsolationLevel il) { return GetConnection(true).BeginTransaction(il); }
0
20. Example
View licensepublic virtual void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified) { var objectContext = ((IObjectContextAdapter) _context).ObjectContext; if (objectContext.Connection.State != ConnectionState.Open) { objectContext.Connection.Open(); } Transaction = objectContext.Connection.BeginTransaction(isolationLevel); }
0
21. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel) { OpenConnection(); DbTransaction trans = Command.Connection.BeginTransaction(isolationLevel); Command.Transaction = trans; }
0
22. Example
View licenseprotected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { if (isolationLevel == IsolationLevel.Unspecified) return BeginTransaction(); return BeginTransaction(isolationLevel); }
0
23. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel) { OpenConnection(); DbTransaction trans = Command.Connection.BeginTransaction(isolationLevel); Command.Transaction = trans; }
0
24. Example
View licensepublic void Start() { if (!Started) { Connection = Connector.Current.CreateConnection(); Connection.Open(); Transaction = Connection.BeginTransaction(IsolationLevel ?? Connector.Current.IsolationLevel); Started = true; } }
0
25. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel) { OpenConnection(); DbTransaction trans = Command.Connection.BeginTransaction(isolationLevel); Command.Transaction = trans; }
0
26. Example
View licensepublic static IDbTransaction BeginTransaction([NotNull] this IDbAccess dbAccess, IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted) { CodeContracts.VerifyNotNull(dbAccess, "dbAccess"); return dbAccess.CreateConnectionOpen().BeginTransaction(isolationLevel); }
0
27. Example
View licensepublic static DbTransaction BeginTransaction(this ObjectContext context, IsolationLevel isolationLevel = IsolationLevel.Unspecified) { if (context == null) throw new ArgumentNullException("context"); if (context.Connection.State != ConnectionState.Open) context.Connection.Open(); return context.Connection.BeginTransaction(isolationLevel); }
0
28. Example
View licensepublic static DbTransaction BeginTransaction(this Database database, System.Data.IsolationLevel isolationLevel) { return database.GetOpenConnection().Connection.BeginTransaction(isolationLevel); }
0
29. Example
View licensepublic static DbTransaction BeginTransaction( this DbCommand dbCommand, IsolationLevel isolationLevel ) { dbCommand.OpenConnection(); DbTransaction transaction = dbCommand.Connection.BeginTransaction( isolationLevel ); dbCommand.SetTransaction( transaction ); return transaction; }
0
30. Example
View licenseprivate Task<DataSessionState> BeginSession(TransactionContext transactionContext) { if (transactionContext == null) throw new ArgumentNullException(nameof(transactionContext)); return Task.Run( () => { var state = new DataSessionState(); WriteOperationTrace(state, "beginSession"); WriteOperationTrace(state, "createConnection"); state.Connection = new MockConnection { ConnectionString = $"MockDataSource.Id={this.Id},TransactionGroupName={this.TransactionGroupName}" }; WriteOperationTrace(state, "openConnection"); state.Connection.Open(); if (transactionContext.Affinity != TransactionContextAffinity.NotSupported) { WriteOperationTrace(state, "beginTransaction"); state.Transaction = state.Connection.BeginTransaction(transactionContext.IsolationLevel); } return state; }); }
0
31. Example
View licensepublic void BeginTransaction( IsolationLevel isolationLevel ) { if( IsOpen ) { throw new InvalidOperationException( "Transaction already open." ); } //Open connection try { this._connection.Open(); this._transaction = this._connection.BeginTransaction( isolationLevel ); this._transactionOpen = true; } catch ( Exception ) { // in the event of an error, close the connection and destroy the transaction object. if ( this._connection != null ) { this._connection.Close(); } if ( this._transaction != null ) { this._transaction.Dispose(); } this._transactionOpen = false; throw; } }
0
32. Example
View licensepublic void BeginTransaction( IsolationLevel isolationLevel ) { if( IsOpen ) { throw new InvalidOperationException( "Transaction already open." ); } //Open connection try { this._connection.Open(); this._transaction = this._connection.BeginTransaction( isolationLevel ); this._transactionOpen = true; } catch ( Exception ) { // in the event of an error, close the connection and destroy the transaction object. if ( this._connection != null ) { this._connection.Close(); } if ( this._transaction != null ) { this._transaction.Dispose(); } this._transactionOpen = false; throw; } }
0
33. Example
View licensepublic virtual DbConnection GetDbConnection(string connectionString, bool rollbackOnScopeStatusFailure) { if (connectionString == null) throw new ArgumentNullException(nameof(connectionString)); if (!_connections.ContainsKey(connectionString)) { TDbConnection newConnection = new TDbConnection { ConnectionString = connectionString }; newConnection.Open(); DbTransaction transaction = newConnection.BeginTransaction(IsolationLevel.ReadCommitted); _connections.Add(connectionString, new DbConnectionAndTransactionPair(newConnection, transaction, rollbackOnScopeStatusFailure)); } return _connections[connectionString].Connection; }
0
34. Example
View licensepublic virtual async Task<DbConnection> GetDbConnectionAsync(string connectionString, bool rollbackOnScopeStatusFailure, CancellationToken cancellationToken) { if (connectionString == null) throw new ArgumentNullException(nameof(connectionString)); if (!_connections.ContainsKey(connectionString)) { TDbConnection newDbConnection = new TDbConnection { ConnectionString = connectionString }; await newDbConnection.OpenAsync(cancellationToken).ConfigureAwait(false); DbTransaction transaction = newDbConnection.BeginTransaction(IsolationLevel.ReadCommitted); _connections.Add(connectionString, new DbConnectionAndTransactionPair(newDbConnection, transaction, rollbackOnScopeStatusFailure)); } return _connections[connectionString].Connection; }
0
35. Example
View licensevoid IMigration<DbConnection>.RunMigration(MigrationRunData<DbConnection> data) { this.Connection = data.Connection; this.Logger = data.Logger; if (this.UseTransaction) { using (this.Transaction = this.Connection.BeginTransaction(IsolationLevel.Serializable)) { try { if (data.Direction == MigrationDirection.Up) this.Up(); else this.Down(); this.Transaction.Commit(); } catch { this.Transaction?.Rollback(); throw; } finally { this.Transaction = null; } } } else { if (data.Direction == MigrationDirection.Up) this.Up(); else this.Down(); } }
0
36. Example
View licenseprivate void InternalUpgrade(bool forceFullUpdate) { FillMetaData(); using (transatedConnection = connection) { using (transaction = connection.BeginTransaction(IsolationLevel.Serializable)) { ProcessUpgrade(forceFullUpdate); foreach (var update in finalUpdates) ExecuteNonQuery(update); transaction.Commit(); } } }
0
37. Example
View licensepublic void Begin(IsolationLevel isolationLevel) { using (session.BeginProcess()) { if (begun) { return; } if (commitFailed) { throw new TransactionException("Cannot restart transaction after failed commit"); } if (isolationLevel == IsolationLevel.Unspecified) { isolationLevel = session.Factory.Settings.IsolationLevel; } log.Debug(string.Format("Begin ({0})", isolationLevel)); try { if (isolationLevel == IsolationLevel.Unspecified) { trans = session.Connection.BeginTransaction(); } else { trans = session.Connection.BeginTransaction(isolationLevel); } } catch (HibernateException) { // Don't wrap HibernateExceptions throw; } catch (Exception e) { log.Error("Begin transaction failed", e); throw new TransactionException("Begin failed with SQL exception", e); } begun = true; committed = false; rolledBack = false; session.AfterTransactionBegin(this); foreach (var dependentSession in session.ConnectionManager.DependentSessions) dependentSession.AfterTransactionBegin(this); } }
0
38. Example
View licensepublic void Transaction(Func<bool> action) { using(var tx = _connection.BeginTransaction(TransactionIsolation)) { var shouldRollback = false; _txStack.Push(tx); try { shouldRollback = !action(); } catch { shouldRollback = true; throw; } finally { if(shouldRollback) { _cache.Clear(); tx.Rollback(); } else { tx.Commit(); } _txStack.Pop(); } } }
0
39. Example
View licensepublic DataConnectionTransaction BeginTransaction(Statement statement) { // If transaction is open, we dispose it, it will rollback all changes. // if (Transactions != null) Transactions.Dispose(); // Create new transaction object. DbConnection connection = null; try { connection = CreateConnection(); connection.Open(); } catch { if (connection != null) connection.Close(); throw; } if (statement.Hints != null && statement.Hints.Contains(DALExtStatementConstant.ISOLATION_LEVEL)) { var level = (System.Data.IsolationLevel)statement.Hints[DALExtStatementConstant.ISOLATION_LEVEL]; Transactions = connection.BeginTransaction(level); } else { Transactions = connection.BeginTransaction(); } _closeTransaction = true; return new DataConnectionTransaction(new ConnectionWrapper(connection, this)); }
0
40. Example
View licenseinternal static Task<int> ExecuteAsync(this IDatabaseConnectionDescriptor descriptor, string query) { return descriptor .GetTaskFactory(true) .StartNew(() => { using (descriptor.AcquireWriteLock()) { try { using (var con = descriptor.GetConnection()) using (var tr = con.BeginTransaction(DefaultIsolationLevel)) { var result = con.Execute(query, transaction: tr); tr.Commit(); return result; } } catch (Exception ex) { throw WrapException(ex, "ExecuteAsync", query); } } }, TaskCreationOptions.DenyChildAttach); }
0
41. Example
View licenseinternal static Task<int> ExecuteAsync(this IDatabaseConnectionDescriptor descriptor, string query, object param) { return descriptor .GetTaskFactory(true) .StartNew(() => { using (descriptor.AcquireWriteLock()) { try { // System.Diagnostics.Debug.WriteLine("EXECUTE: " + query); using (var con = descriptor.GetConnection()) using (var tr = con.BeginTransaction(DefaultIsolationLevel)) { var result = con.Execute(query, param, tr); tr.Commit(); return result; } } catch (Exception ex) { throw WrapException(ex, "ExecuteAsyncWithParam", query); } } }, TaskCreationOptions.DenyChildAttach); }
0
42. Example
View licenseinternal static void DbTransaction() { using (DbConnection connection = new SqlC/n ..... /n //View Source file for more details /n }
0
43. Example
View licenseinternal static Task ExecuteAllAsync(this IDatabaseConnectionDescriptor descriptor, IEnumerable<Tuple<string, object>> queryAndParams) { var qnp = queryAndParams.Memoize(); return descriptor .GetTaskFactory(true) .StartNew(() => { using (descriptor.AcquireWriteLock()) { try { using (var con = descriptor.GetConnection()) using (var tr = con.BeginTransaction(DefaultIsolationLevel)) { foreach (var tuple in qnp) { // tuple := (query, param) // System.Diagnostics.Debug.WriteLine("EXECUTE: " + qap.Item1); con.Execute(tuple.Item1, tuple.Item2, tr); } tr.Commit(); } } catch (Exception ex) { throw WrapException(ex, "ExecuteAllAsync", qnp.Select(q => q.Item1).JoinString(Environment.NewLine)); } } }, TaskCreationOptions.DenyChildAttach); }
0
44. Example
View licensepublic void ExecuteNonQuery(SqlNonQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); using (var dbConnection = _dbProviderFactory.CreateConnection()) { dbConnection.ConnectionString = _settings.ConnectionString; dbConnection.Open(); try { using (var dbTransaction = dbConnection.BeginTransaction(_isolationLevel)) { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.Transaction = dbTransaction; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); } dbTransaction.Commit(); } } finally { dbConnection.Close(); } } }
0
45. Example
View licensepublic async Task ExecuteNonQueryAsync(SqlNonQueryCommand command, CancellationToken cancellationToken) { if (command == null) throw new ArgumentNullException("command"); using (var dbConnection = _dbProviderFactory.CreateConnection()) { dbConnection.ConnectionString = _settings.ConnectionString; await dbConnection.OpenAsync(cancellationToken); try { using (var dbTransaction = dbConnection.BeginTransaction(_isolationLevel)) { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.Transaction = dbTransaction; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); } dbTransaction.Commit(); } } finally { dbConnection.Close(); } } }
0
46. Example
View licenseinternal static void DbTransaction() { using (DbConnection connection = new SqlC/n ..... /n //View Source file for more details /n }
0
47. Example
View license[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Micr/n ..... /n //View Source file for more details /n }
0
48. Example
View licensepublic static DataTable RunCommand(string connectionString, string rawScript, SqlCommandType command/n ..... /n //View Source file for more details /n }
0
49. Example
View licensepublic int ExecuteNonQuery(IEnumerable<SqlNonQueryCommand> commands) { if /n ..... /n //View Source file for more details /n }
0
50. Example
View licensepublic async Task<int> ExecuteNonQueryAsync(IEnumerable<SqlNonQueryCommand> commands, Ca/n ..... /n //View Source file for more details /n }