Stored Procedure return values with linq data context Stored Procedure return values with linq data context sql-server sql-server

Stored Procedure return values with linq data context


Why are you all using a stored procedure as function?

Though a stored procedure has return, it is not a function, so you should not use return to return data,

Rather, you should use Output parameters and other ways to return data, as documented at MSDN

And the use of return is documented at MSDN

misusing return is probably the reason why LINQ does not understand your stored procedures.


this was I did and it worked.

In Sqlserver:

   ALTER PROCEDURE [dbo].[ValidateToken]-- Add the parameters for the stored procedure here@Id intASBEGINDECLARE @Ret INTSELECT    @Ret = COUNT(*)FROM Testset @Ret =@Id+1;select @RetEND

In C#:

 static void Main(string[] args)    {        using (SergioEntities dm = new SergioEntities())         {            int? validToken = 1;            int? a = dm.ValidateToken(validToken).First();        }    }

Give it a try :)


Try to change the RETURN 0/1 statements to SELECT 0/1