How to execute stored procedure and get return result in MVC/EF/LINQ

asp.net-mvc c# entity-framework linq sql-server-2008

Accepted Answer

Your issue is that you're utilizing a saved process to return the value.RETURN @paramter2 ), but the code in your.NET application is attempting to read a result set that would be "returned" by using aSELECT ..... within the stored procedure statement

Define your stored procedure as follows:

CREATE PROCEDURE dbo.StoredProcedure2 AS
     declare @parameter2 int
     SET @parameter2 = 4

     SELECT @parameter2 

then your.NET code ought to run without a hitch.

The RETURN only be utilized for status symbols and has the ability to returnINT values alone You must define an if you want to use that.SqlParameter a predefined process for yourDirection.ReturnValue

9
10/2/2013 6:11:13 PM

Popular Answer

For information on how to map theStored Procedure to your situation:

Procedures for Storing Data in the Entity Framework

Following the mapping, you can call theStored Procedure such a way:

var val = _context.StoredProcedure2();


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow