TopShelfCustomer/TopShelfCustomer.Api/Services/SqlDataAccess.cs
/// <summary>
/// SaveData:
///
/// Acts as a write method for the database.
/// </summary>
/// <typeparam name="T"> The type of the parameters passed to the SQL query </typeparam>
/// <param name="storedProcedure"> The SQL procedure to use on the database </param>
/// <param name="parameters"> The parameters for the SQL query </param>
/// <param name="connectionStringName"> The shortened name of the SQL connection string </param>


Acts as a write method for the database.
Acts as a write method for the database .
public void SaveData<T> ( string storedProcedure, T parameters, string connectionStringName ) {
            string connectionString = GetConnectionString( connectionStringName );      
            using ( IDbConnection connection = new SqlConnection( connectionString ) ) {        
                connection.Execute( storedProcedure,
                    parameters, commandType: CommandType.StoredProcedure );
            }
        }
public void SaveData < T > ( string storedProcedure , T parameters , string connectionStringName ) { string connectionString = GetConnectionString ( connectionStringName ) ; using ( IDbConnection connection = new SqlConnection ( connectionString ) ) { connection . Execute ( storedProcedure , parameters , commandType : CommandType . StoredProcedure ) ; } }
SaveData:
SaveData :
//The full connection string //Database connection and Query
storedProcedure
string
The SQL procedure to use on the database
The SQL procedure to use on the database
parameters
T
The parameters for the SQL query
The parameters for the SQL query
connectionStringName
string
The shortened name of the SQL connection string
The shortened name of the SQL connection string
typeparam
The type of the parameters passed to the SQL query
The type of the parameters passed to the SQL query