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(); } }
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); }
public IList <TMapped> ExecMappedStoredProcedure <TMapped>(string procedureName, StoredProcedureParameters inputParameters, IStoredProcedureResultMapper <TMapped> mapper) { DataTable result = this.ExecDataTableStoredProcedure(procedureName, inputParameters); return(mapper.Map(result)); }
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); } }