How to retrieve an int from Stored Procedure and not an objectResult using EF ???


Hi,

 

im trying to set data from my project (mvc.net,c#) by web service and im using a store Procedure to set the data.

after setting i should recive an int id of the record that was created.

my problem is that the SP returns an objectResult when i run it from my project but when i execute it in SQL it returns int...

How to retrieve an int from Stored Procedure using EF ???


Asked by:- DaveO'Neill
1
: 281 At:- 7/13/2017 1:15:14 PM
sql web service

Can you show me your stored procedure code? And images of sql server returned results, it would be helpful to identify issue 0
By : vikas_jk - at :- 7/13/2017 1:24:39 PM





2 Answers
profileImage Answered by:- DaveO'Neill

Thanks @Vikas!

your second option worked for me:

  1. Move to your .edmx
  2. At Model Browser, Window/Function Imports find your procedure then double click it
  3. Change the return type to you want
  4. Save .edmx and check the return type again.
2
At:- 7/16/2017 7:44:03 AM
great, thanks for commenting it will help other users 0
By : vikas_jk - at :- 7/18/2017 7:46:40 AM


profileImage Answered by:- vikas_jk

A possible solution to your question can be as it appears that Entity Framework gets confused as to what should be returned by the procedure. The solution I've come across is to add this at the top of the sproc:

SET FMTONLY OFF

It may resolve your issue.

Another possible solution can be:

  1. Move to your .edmx
  2. At Model Browser, Window/Function Imports find your procedure then double click it
  3. Change the return type to you want
  4. Save .edmx and check the return type again.

Check Link for Details

0
At:- 7/13/2017 3:05:48 PM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly