public void ExecuteInterruptibleReader(T arg, bool singleRow, string commandText, CommandType commandType, DbExecutionParameters executionParameters, Func <DbDataReader, bool> handleOneRow, params DbParameter[] parameters) { DbHelper.ExecuteInterruptibleReader(_selector.GetConnectionString(arg), singleRow, commandText, commandType, executionParameters, handleOneRow, parameters); }
public async Task ExecuteInterruptibleReaderAsync(T arg, bool singleRow, string commandText, CommandType commandType, DbExecutionParameters executionParameters, Func <DbDataReader, Task <bool> > handleOneRow, params DbParameter[] parameters) { await DbHelper.ExecuteInterruptibleReaderAsync(_selector.GetConnectionString(arg), singleRow, commandText, commandType, executionParameters, handleOneRow, parameters); }
public async Task ExecuteReaderAsync(bool singleRow, string commandText, CommandType commandType, DbExecutionParameters executionParameters, Action <DbDataReader> handleOneRow, params DbParameter[] parameters) { await DbHelper.ExecuteReaderAsync(_connectionString, singleRow, commandText, commandType, executionParameters, handleOneRow, parameters); }
public async Task ExecuteReaderAsync(T arg, string commandText, DbExecutionParameters executionParameters, Action <DbDataReader> handleOneRow, params DbParameter[] parameters) { await DbHelper.ExecuteReaderAsync(_selector.GetConnectionString(arg), commandText, executionParameters, handleOneRow, parameters); }
public void ExecuteReader(string commandText, DbExecutionParameters executionParameters, Action <DbDataReader> handleOneRow, params DbParameter[] parameters) { DbHelper.ExecuteReader(_connectionString, commandText, executionParameters, handleOneRow, parameters); }
public async static Task ExecuteInterruptibleReaderAsync(string connectionString, bool singleRow, string commandText, CommandType commandType, DbExecutionParameters executionParameters, Func <DbDataReader, Task <bool> > handleOneRow, params DbParameter[] parameters) { using (var connection = _factory.CreateConnection()) { connection.ConnectionString = connectionString; connection.Open(); var logContext = LogBegin("ExecuteInterruptibleReaderAsync", connection, commandText, parameters); try { using (var cmd = _factory.CreateCommand()) { cmd.Connection = connection; cmd.CommandText = commandText; cmd.CommandType = commandType; if (executionParameters != null && executionParameters.CommandTimeout.HasValue) { cmd.CommandTimeout = executionParameters.CommandTimeout.Value; } cmd.Parameters.AddRange(parameters); using (var reader = await cmd.ExecuteReaderAsync()) { while (reader.Read()) { if (await handleOneRow(reader)) { break; } if (singleRow) { break; } } } } } finally { LogEnd(logContext); } } }
public static async Task ExecuteReaderAsync(string connectionString, string commandText, DbExecutionParameters executionParameters, Action <DbDataReader> handleOneRow, params DbParameter[] parameters) { await ExecuteReaderAsync(connectionString, false, commandText, CommandType.Text, executionParameters, handleOneRow, parameters); }
public static void ExecuteReader(string connectionString, bool singleRow, string commandText, CommandType commandType, DbExecutionParameters executionParameters, Action <DbDataReader> handleOneRow, params DbParameter[] parameters) { using (var connection = _factory.CreateConnection()) { if (executionParameters != null && executionParameters.ConnectionTimeout.HasValue) { var connectionStringBuilder = _factory.CreateConnectionStringBuilder(); connectionStringBuilder.ConnectionString = connectionString; if (connectionStringBuilder is SqlConnectionStringBuilder) { ((SqlConnectionStringBuilder)connectionStringBuilder).ConnectTimeout = executionParameters.ConnectionTimeout.Value; } else { throw new Exception("Do not support setting ConnectionTimeout on " + connectionStringBuilder.GetType().ToString()); } connectionString = connectionStringBuilder.ToString(); } connection.ConnectionString = connectionString; connection.Open(); var logContext = LogBegin("ExecuteReader", connection, commandText, parameters); try { using (var cmd = _factory.CreateCommand()) { cmd.Connection = connection; cmd.CommandText = commandText; cmd.CommandType = commandType; if (executionParameters != null && executionParameters.CommandTimeout.HasValue) { cmd.CommandTimeout = executionParameters.CommandTimeout.Value; } cmd.Parameters.AddRange(parameters); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { handleOneRow(reader); if (singleRow) { break; } } } } } finally { LogEnd(logContext); } } }
public static void ExecuteReader(string connectionString, string commandText, DbExecutionParameters executionParameters, Action <DbDataReader> handleOneRow, params DbParameter[] parameters) { ExecuteReader(connectionString, false, commandText, CommandType.Text, executionParameters, handleOneRow, parameters); }