Using (IDbConnection conn = WebDbConn. DbService ()){
Conn. Execute (@"
Create proc # TestOutputParameterProc @ Foo int, @ Bar int out
Set @ Bar = @ Foo select 1 as [A] select 2 as [B] ");
Try
{
Var args = new DynamicParameters (new {Foo = 123 });
Args. Add ("@ Bar", dbType: DbType. Int32,
Direction: ParameterDirection. Output );
Using (var grids = conn. QueryMultiple ("# TestOutputParameterProc ",
Args, commandType: CommandType. StoredProcedure ))
{
// This will fail here; we have not consumed the TDS data yet!
// Args. Get <int> ("@ Bar"). isdue to (123 );
// Note we don't * have * to read the data here; disposing "grids"
// Wocould be enough to skip to the end of the TDS
// Var A = grids. Read <int> (). Single (). Equals (1); //
// Var B = grids. Read <int> (). Single (). Equals (2); // B
Var A = grids. Read <int> (). Single (); //
Var B = grids. Read <int> (). Single (); // B
}
// At this point we have consumed the TDS data, so the parameter
// Values have come back to the caller
Args. Get <int> ("@ Bar"). Equals (123 );
}
Finally
{// Clean up the proc
Conn. Execute ("drop proc # TestOutputParameterProc ");
}
Stored Procedure Return Value
Http://stackoverflow.com/questions/9870969/can-dapper-return-values-from-a-sql-function/9871380#9871380
Http://stackoverflow.com/questions/14723277/dapper-output-parameter-is-not-returning-values/14746522#14746522