How to retrieve the Output parameter of a storedProcedure?
SP Example:
create PROCEDURE StoreProcedure_Name
@ParametterWithNummvalue varchar(50) = null,
@In_Parameter varchar(50),
@Out_Parameter varchar(10) out
AS
set @Out_Parameter = 'teste'
RETURN 0
C # code
SqlParameter[] Params = {
new SqlParameter("@ParametterWithNummvalue", DBNull.Value),
new SqlParameter("@In_Parameter", "teste novo"),
new SqlParameter("@Out_Parameter", SqlDbType.VarChar, 10) { Direction = ParameterDirection.Output }};
var r = Db.Database.ExecuteSqlCommand("exec StoreProcedure_Name @ParametterWithNummvalue, @In_Parameter, @Out_Parameter", Params);
var ReturnValue = Params[2].Value;
ReturnValue should contain the value "test" but it is returning empty.