Ejemplo n.º 1
0
        public static DataTable ExecuteDataTable2(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] parameters)
        {
            SqlCommand cmd = new SqlCommand();

            PrepareCommand(cmd, connection, null, commandType, commandText, parameters);
            return(PerformanceWatcher.Watch <DataTable>(commandText, delegate {
                SqlDataAdapter adapter1 = new SqlDataAdapter(cmd)
                {
                    SelectCommand = { CommandTimeout = 0 }
                };
                DataTable dataTable = new DataTable();
                adapter1.Fill(dataTable);
                cmd.Parameters.Clear();
                return dataTable;
            }));
        }
Ejemplo n.º 2
0
        private static SqlDataReader ExecuteReader(SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, SqlConnectionOwnership connectionOwnership)
        {
            SqlDataReader reader;
            SqlCommand    cmd = new SqlCommand();

            PrepareCommand(cmd, connection, transaction, commandType, commandText, commandParameters);
            if (connectionOwnership == SqlConnectionOwnership.External)
            {
                reader = PerformanceWatcher.Watch <SqlDataReader>(commandText, () => cmd.ExecuteReader());
            }
            else
            {
                reader = PerformanceWatcher.Watch <SqlDataReader>(commandText, () => cmd.ExecuteReader(CommandBehavior.CloseConnection));
            }
            cmd.Parameters.Clear();
            return(reader);
        }