I am trying to return a scalar value from a stored procedure. I really want to return the ID of the newly created record, but I simplified my problem to a stored procedure that accepts intand tries to return the same one int. This always returns -1. Thank you so much for your help.
Web API Manager Call
var idtest = dbconn.my_return_int(123);
Stored procedure:
ALTER PROCEDURE [dbo].[my_return_int]
@ID int
AS
BEGIN
SET NOCOUNT ON;
DECLARE @return as int
SET @return = -999
RETURN @return
END
The generated stored procedure call Context
public virtual int my_return_int(Nullable<int> iD)
{
var iDParameter = iD.HasValue ?
new ObjectParameter("ID", iD) :
new ObjectParameter("ID", typeof(int));
return (IObjectContextAdapter)this).ObjectContext.ExecuteFunction("my_return_int", iDParameter);
}
mschu source
share