public static IDataReader ExecuteReader(IDbCommand command, string description, bool isApplication, bool transformParameters, bool skipLog) { try { // Save the values before execution because sometimes the drivers clears them from the IDbCommand when an exception occurs IDbCommand cmd = ADOAdaptersUtils.GetADOCommand(command); IDbConnection conn = cmd.Connection; IDbTransaction trans = cmd.Transaction; IDatabaseAccessProvider provider = null; bool hasProvider = trans != null && DatabaseAccess.TryGetProviderForTransaction(trans, out provider); IExecutionService executionService = hasProvider ? provider.DatabaseServices.ExecutionService : GetExecutionForConnection(conn); ITransactionManager manager = provider.TransactionManager; IDataReader reader = null; try { if (transformParameters) { TransformParameters(cmd); } reader = executionService.ExecuteReader(cmd); // NOTE: This reader will be closed automatically by the transaction manager at the end of the request manager.AssociateReader(trans, reader); } catch (DbException e) { executionService.OnExecuteException(e, cmd, reader, conn, trans, manager); throw; } return(reader); } catch (InvalidDatabaseAccessException e) { throw new InvalidDBTransactionManagerAccess(e.Message); } }
public static DataSet CreateAndFillDataSet(IDbCommand command, IDbDataAdapter adapter, string description, bool isApplication) { // Save the values before execution because sometimes the drivers clears them from the IDbCommand when an exception occurs IDbCommand cmd = ADOAdaptersUtils.GetADOCommand(command); IDbConnection conn = cmd.Connection; IDbTransaction trans = cmd.Transaction; IDatabaseAccessProvider provider = null; bool hasProvider = trans != null && DatabaseAccess.TryGetProviderForTransaction(trans, out provider); IExecutionService executionService = hasProvider ? provider.DatabaseServices.ExecutionService : GetExecutionForConnection(conn); ITransactionManager manager = provider.TransactionManager; try { DataSet dataSet; { dataSet = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(dataSet); } return(dataSet); } catch (DbException e) { executionService.OnExecuteException(e, cmd, null, conn, trans, manager); throw; } }