Example #1
0
        public void ExecStoredProcedure(string procedureName, StoredProcedureParameters parameters)
        {
            using (SqlConnection sqlConnection = GetSqlConnection())
                using (SqlCommand command = new SqlCommand(procedureName, sqlConnection))
                {
                    sqlConnection.Open();

                    command.CommandType = CommandType.StoredProcedure;

                    parameters.AddParametersToCommand(command);

                    command.ExecuteNonQuery();
                }
        }
Example #2
0
        public DataTable ExecDataTableStoredProcedure(string procedureName, StoredProcedureParameters parameters)
        {
            DataTable dataTable = new DataTable();

            using (SqlConnection sqlConnection = GetSqlConnection())
                using (SqlCommand command = new SqlCommand(procedureName, sqlConnection))
                    using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
                    {
                        sqlConnection.Open();

                        command.CommandType = CommandType.StoredProcedure;

                        parameters.AddParametersToCommand(command);

                        dataAdapter.Fill(dataTable);
                    }

            return(dataTable);
        }
Example #3
0
        public IList <TMapped> ExecMappedStoredProcedure <TMapped>(string procedureName, StoredProcedureParameters inputParameters, IStoredProcedureResultMapper <TMapped> mapper)
        {
            DataTable result = this.ExecDataTableStoredProcedure(procedureName, inputParameters);

            return(mapper.Map(result));
        }
Example #4
0
        public TOutput ExecSingleOutputStoredProcedure <TOutput>(string procedureName, StoredProcedureParameters parameters, string outputParameterName)
        {
            using (SqlConnection sqlConnection = GetSqlConnection())
                using (SqlCommand command = new SqlCommand(procedureName, sqlConnection))
                {
                    sqlConnection.Open();

                    command.CommandType = CommandType.StoredProcedure;

                    parameters.AddParametersToCommand(command);

                    command.Parameters.Add(outputParameterName, SqlDbTypes.Of(typeof(TOutput))).Direction = ParameterDirection.Output;

                    command.ExecuteNonQuery();
                    return((TOutput)command.Parameters[outputParameterName].Value);
                }
        }