using Dapper; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RMDataManagerLibrary.Internal.DataAccess { public class SqlDataAccess { public string GetConnectionString(string name) { return ConfigurationManager.ConnectionStrings[name].ConnectionString; } public List LoadData(string storedProcedure, U parameters, string connectionStringName) { string connectionString = GetConnectionString(connectionStringName); using (IDbConnection connection = new SqlConnection(connectionString)) { List rows = connection.Query(storedProcedure, parameters, commandType: CommandType.StoredProcedure).ToList(); return rows; } } public void SaveData(string storedProcedure, T parameters, string connectionStringName) { string connectionString = GetConnectionString(connectionStringName); using (IDbConnection connection = new SqlConnection(connectionString)) { connection.Execute(storedProcedure, parameters, commandType: CommandType.StoredProcedure); } } } }