Here are the examples of the csharp api class System.Data.Common.DbParameterCollection.AddRange(System.Array) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
43 Examples
0
1. Example
Project: Goo-Micro-ORM
Source File: DBManager.cs
Source File: DBManager.cs
public void AddParameter(System.Data.SqlClient.SqlParameter[] sqlParams) { if (command != null) command.Parameters.AddRange(sqlParams); }
0
2. Example
Project: nanoprofiler
Source File: DbParameterCollectionWrapper.cs
Source File: DbParameterCollectionWrapper.cs
public override void AddRange(Array values) { if (_dbParameterCollection != null) { _dbParameterCollection.AddRange(values); } else { foreach (var value in values) { Add(value); } } }
0
3. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteDataSet.cs
Source File: MySqlConnection.ExecuteDataSet.cs
public static DataSet ExecuteDataSet(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (var command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } var ds = new DataSet(); using (var dataAdapter = new MySqlDataAdapter(command)) { dataAdapter.Fill(ds); } return ds; } }
0
4. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteDataTable.cs
Source File: MySqlConnection.ExecuteDataTable.cs
public static DataTable ExecuteDataTable(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } var ds = new DataSet(); using (var dataAdapter = new MySqlDataAdapter(command)) { dataAdapter.Fill(ds); } return ds.Tables[0]; } }
0
5. Example
Project: NDF.Infrastructure
Source File: DatabaseExtensions.CreateCommand.cs
Source File: DatabaseExtensions.CreateCommand.cs
public static DbCommand CreateCommand(this Database database, string commandText, params System.Data.Common.DbParameter[] parameterValues) { var command = CreateCommand(database, commandText); command.Parameters.AddRange(parameterValues); return command; }
0
6. Example
Project: NDF.Infrastructure
Source File: DatabaseExtensions.CreateCommand.cs
Source File: DatabaseExtensions.CreateCommand.cs
public static DbCommand CreateCommand(this Database database, string commandText, System.Data.CommandType commandType, params System.Data.Common.DbParameter[] parameterValues) { var command = CreateCommand(database, commandText, commandType); command.Parameters.AddRange(parameterValues); return command; }
0
7. Example
Project: elephant
Source File: DbConnectionExtensions.cs
Source File: DbConnectionExtensions.cs
public static Task<int> ExecuteNonQueryAsync( this DbConnection connection, string commandText, CancellationToken cancellationToken, SqlParameter[] sqlParameters = null) { using (var command = connection.CreateCommand()) { command.CommandText = commandText; command.CommandType = System.Data.CommandType.Text; if (sqlParameters != null && sqlParameters.Length > 0) { command.Parameters.AddRange(sqlParameters); } return command.ExecuteNonQueryAsync(cancellationToken); } }
0
8. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteEntities.cs
Source File: MySqlConnection.ExecuteEntities.cs
public static IEnumerable<T> ExecuteEntities<T>(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) where T : new() { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } using (IDataReader reader = command.ExecuteReader()) { return reader.ToEntities<T>(); } } }
0
9. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteEntity.cs
Source File: MySqlConnection.ExecuteEntity.cs
public static T ExecuteEntity<T>(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) where T : new() { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } using (IDataReader reader = command.ExecuteReader()) { reader.Read(); return reader.ToEntity<T>(); } } }
0
10. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteExpandoObject.cs
Source File: MySqlConnection.ExecuteExpandoObject.cs
public static dynamic ExecuteExpandoObject(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } using (IDataReader reader = command.ExecuteReader()) { reader.Read(); return reader.ToExpandoObject(); } } }
0
11. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteExpandoObjects.cs
Source File: MySqlConnection.ExecuteExpandoObjects.cs
public static IEnumerable<dynamic> ExecuteExpandoObjects(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } using (IDataReader reader = command.ExecuteReader()) { return reader.ToExpandoObjects(); } } }
0
12. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteNonQuery.cs
Source File: MySqlConnection.ExecuteNonQuery.cs
public static void ExecuteNonQuery(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } command.ExecuteNonQuery(); } }
0
13. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteReader.cs
Source File: MySqlConnection.ExecuteReader.cs
public static MySqlDataReader ExecuteReader(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } return command.ExecuteReader(); } }
0
14. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteScalar.cs
Source File: MySqlConnection.ExecuteScalar.cs
public static object ExecuteScalar(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } return command.ExecuteScalar(); } }
0
15. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteScalarAs.cs
Source File: MySqlConnection.ExecuteScalarAs.cs
public static T ExecuteScalarAs<T>(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } return (T) command.ExecuteScalar(); } }
0
16. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public void ExecuteNonQuery(SqlNonQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); } }
0
17. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public async Task ExecuteNonQueryAsync(SqlNonQueryCommand command, CancellationToken cancellationToken) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); } }
0
18. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public DbDataReader ExecuteReader(SqlQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteReader(CommandBehavior.SequentialAccess); } }
0
19. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public object ExecuteScalar(SqlQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteScalar(); } }
0
20. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public Task<object> ExecuteScalarAsync(SqlQueryCommand command, CancellationToken cancellationToken) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteScalarAsync(cancellationToken); } }
0
21. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public Task<DbDataReader> ExecuteReaderAsync(SqlQueryCommand command, CancellationToken cancellationToken) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteReaderAsync(CommandBehavior.SequentialAccess, cancellationToken); } }
0
22. Example
Project: Projac
Source File: ConnectedTransactionalSqlCommandExecutor.cs
Source File: ConnectedTransactionalSqlCommandExecutor.cs
public async Task ExecuteNonQueryAsync(SqlNonQueryCommand command, CancellationToken cancellationToken) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbTransaction.Connection.CreateCommand()) { dbCommand.Connection = _dbTransaction.Connection; dbCommand.Transaction = _dbTransaction; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); } }
0
23. Example
Project: elephant
Source File: DbConnectionExtensions.cs
Source File: DbConnectionExtensions.cs
public static async Task<TResult> ExecuteScalarAsync<TResult>( this DbConnection connection, string commandText, CancellationToken cancellationToken, SqlParameter[] sqlParameters = null) { using (var command = connection.CreateCommand()) { command.CommandText = commandText; command.CommandType = System.Data.CommandType.Text; if (sqlParameters != null && sqlParameters.Length > 0) { command.Parameters.AddRange(sqlParameters); } return (TResult)(await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false)); } }
0
24. Example
Project: Z.ExtensionMethods
Source File: MySqlConnection.ExecuteScalarTo.cs
Source File: MySqlConnection.ExecuteScalarTo.cs
public static T ExecuteScalarTo<T>(this MySqlConnection @this, string cmdText, MySqlParameter[] parameters, CommandType commandType, MySqlTransaction transaction) { using (MySqlCommand command = @this.CreateCommand()) { command.CommandText = cmdText; command.CommandType = commandType; command.Transaction = transaction; if (parameters != null) { command.Parameters.AddRange(parameters); } return command.ExecuteScalar().To<T>(); } }
0
25. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public int ExecuteNonQuery(IEnumerable<SqlNonQueryCommand> commands) { if (commands == null) throw new ArgumentNullException("commands"); using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; var count = 0; foreach (var command in commands) { dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); count++; } return count; } }
0
26. Example
Project: Projac
Source File: ConnectedSqlCommandExecutor.cs
Source File: ConnectedSqlCommandExecutor.cs
public async Task<int> ExecuteNonQueryAsync(IEnumerable<SqlNonQueryCommand> commands, CancellationToken cancellationToken) { if (commands == null) throw new ArgumentNullException("commands"); var count = 0; using (var dbCommand = _dbConnection.CreateCommand()) { dbCommand.Connection = _dbConnection; dbCommand.CommandTimeout = _commandTimeout; foreach (var command in commands) { dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); count++; } } return count; }
0
27. Example
Project: Projac
Source File: ConnectedTransactionalSqlCommandExecutor.cs
Source File: ConnectedTransactionalSqlCommandExecutor.cs
public void ExecuteNonQuery(SqlNonQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); using (var dbCommand = _dbTransaction.Connection.CreateCommand()) { dbCommand.Connection = _dbTransaction.Connection; dbCommand.Transaction = _dbTransaction; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); } }
0
28. Example
Project: Projac
Source File: ConnectedTransactionalSqlCommandExecutor.cs
Source File: ConnectedTransactionalSqlCommandExecutor.cs
public int ExecuteNonQuery(IEnumerable<SqlNonQueryCommand> commands) { if (commands == null) throw new ArgumentNullException("commands"); var count = 0; using (var dbCommand = _dbTransaction.Connection.CreateCommand()) { dbCommand.Connection = _dbTransaction.Connection; dbCommand.Transaction = _dbTransaction; dbCommand.CommandTimeout = _commandTimeout; foreach (var command in commands) { dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); count++; } } return count; }
0
29. Example
Project: Projac
Source File: ConnectedTransactionalSqlCommandExecutor.cs
Source File: ConnectedTransactionalSqlCommandExecutor.cs
public async Task<int> ExecuteNonQueryAsync(IEnumerable<SqlNonQueryCommand> commands, CancellationToken cancellationToken) { if (commands == null) throw new ArgumentNullException("commands"); var count = 0; using (var dbCommand = _dbTransaction.Connection.CreateCommand()) { dbCommand.Connection = _dbTransaction.Connection; dbCommand.Transaction = _dbTransaction; dbCommand.CommandTimeout = _commandTimeout; foreach (var command in commands) { dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); count++; } } return count; }
0
30. Example
Project: AntiSQLi
Source File: AntiSQLiCommon.cs
Source File: AntiSQLiCommon.cs
public static void ParameterizeAndLoadQuery<TParameterType>(String QueryText, DbCommand DbComm/n ..... /n //View Source file for more details /n }
0
31. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public 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 dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); } } finally { dbConnection.Close(); } } }
0
32. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public DbDataReader ExecuteReader(SqlQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); var dbConnection = _dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = _settings.ConnectionString; dbConnection.Open(); try { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SequentialAccess); } } catch { dbConnection.Close(); throw; } }
0
33. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public object ExecuteScalar(SqlQueryCommand command) { if (command == null) throw new ArgumentNullException("command"); var dbConnection = _dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = _settings.ConnectionString; dbConnection.Open(); try { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteScalar(); } } catch { dbConnection.Close(); throw; } }
0
34. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public async Task<DbDataReader> ExecuteReaderAsync(SqlQueryCommand command, CancellationToken cancellationToken) { if (command == null) throw new ArgumentNullException("command"); var dbConnection = _dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = _settings.ConnectionString; await dbConnection.OpenAsync(cancellationToken); try { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); return await dbCommand.ExecuteReaderAsync(CommandBehavior.CloseConnection | CommandBehavior.SequentialAccess, cancellationToken); } } catch { dbConnection.Close(); throw; } }
0
35. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public 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 dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); } } finally { dbConnection.Close(); } } }
0
36. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public int ExecuteNonQuery(IEnumerable<SqlNonQueryCommand> commands) { if (commands == null) throw new ArgumentNullException("commands"); using (var dbConnection = _dbProviderFactory.CreateConnection()) { dbConnection.ConnectionString = _settings.ConnectionString; dbConnection.Open(); try { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; var count = 0; foreach (var command in commands) { dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); dbCommand.ExecuteNonQuery(); count++; } return count; } } finally { dbConnection.Close(); } } }
0
37. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public async Task<int> ExecuteNonQueryAsync(IEnumerable<SqlNonQueryCommand> commands, CancellationToken cancellationToken) { if (commands == null) throw new ArgumentNullException("commands"); using (var dbConnection = _dbProviderFactory.CreateConnection()) { dbConnection.ConnectionString = _settings.ConnectionString; await dbConnection.OpenAsync(cancellationToken); try { using (var dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; var count = 0; foreach (var command in commands) { dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); await dbCommand.ExecuteNonQueryAsync(cancellationToken); count++; } return count; } } finally { dbConnection.Close(); } } }
0
38. Example
Project: Projac
Source File: SqlCommandExecutor.cs
Source File: SqlCommandExecutor.cs
public async Task<object> ExecuteScalarAsync(SqlQueryCommand 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 dbCommand = dbConnection.CreateCommand()) { dbCommand.Connection = dbConnection; dbCommand.CommandTimeout = _commandTimeout; dbCommand.CommandType = command.Type; dbCommand.CommandText = command.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddRange(command.Parameters); return dbCommand.ExecuteScalarAsync(cancellationToken); } } finally { dbConnection.Close(); } } }
0
39. Example
Project: Projac
Source File: TransactionalSqlCommandExecutor.cs
Source File: TransactionalSqlCommandExecutor.cs
public 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
40. Example
Project: Projac
Source File: TransactionalSqlCommandExecutor.cs
Source File: TransactionalSqlCommandExecutor.cs
public 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
41. Example
Project: SmartStoreNET
Source File: ObjectContextBase.cs
Source File: ObjectContextBase.cs
private IList<TEntity> ExecuteStoredProcedureListLegacy<TEntity>(string commandText, IEnumerable<DbParameter> parameters) where TEntity : BaseEntity, new() { var connection = this.Database.Connection; // Don't close the connection after command execution // open the connection for use if (connection.State == ConnectionState.Closed) connection.Open(); // create a command object using (var cmd = connection.CreateCommand()) { // command to execute cmd.CommandText = commandText; cmd.CommandType = CommandType.StoredProcedure; // move parameters to command object cmd.Parameters.AddRange(parameters.ToArray()); // database call var reader = cmd.ExecuteReader(); var result = ((IObjectContextAdapter)(this)).ObjectContext.Translate<TEntity>(reader).ToList(); if (!ForceNoTracking) { for (int i = 0; i < result.Count; i++) { result[i] = Attach(result[i]); } } // close up the reader, we're done saving results reader.Close(); return result; } }
0
42. Example
Project: Projac
Source File: TransactionalSqlCommandExecutor.cs
Source File: TransactionalSqlCommandExecutor.cs
public int ExecuteNonQuery(IEnumerable<SqlNonQueryCommand> commands) { if /n ..... /n //View Source file for more details /n }
0
43. Example
Project: Projac
Source File: TransactionalSqlCommandExecutor.cs
Source File: TransactionalSqlCommandExecutor.cs
public async Task<int> ExecuteNonQueryAsync(IEnumerable<SqlNonQueryCommand> commands, Ca/n ..... /n //View Source file for more details /n }