public void Example8_Dapper()
{
using (var cnn = new SqlConnection(s_ConnectionString))
{
var user = cnn.Query<User>("spGetUser", new { Id = 1 }, commandType: CommandType.StoredProcedure).SingleOrDefault();
}
//With OUT parameters
using (var cnn = new SqlConnection(s_ConnectionString))
{
var p = new DynamicParameters();
p.Add("@a", 11);
p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
cnn.Execute("spMagicProc", p, commandType: CommandType.StoredProcedure);
int b = p.Get<int>("@b");
int c = p.Get<int>("@c");
Assert.AreEqual(10, b);
Assert.AreEqual(5, c);
}
}