I\'m using Dapper (thanks Sam, great project.) a micro ORM with a DAL and by some reason I\'m not able to execute stored procedures with input parameters.
In a exam
You'll need to extend it to support outbound parameters and returning results, but it contains the portion for creating the Dapper dynamic parameters.
internal static bool ExecuteProc(string sql, List paramList = null)
{
try
{
using (SqlConnection conn = new SqlConnection (GetConnectionString()))
{
DynamicParameters dp = new DynamicParameters();
if(paramList != null)
foreach (SqlParameter sp in paramList)
dp.Add(sp.ParameterName, sp.SqlValue, sp.DbType);
conn.Open();
return conn.Execute(sql, dp, commandType: CommandType.StoredProcedure) > 0;
}
}
catch (Exception e)
{
//do logging
return false;
}
}