I updated my Model with my Stored procedure and in the model browser I can see it has a Function import as well.
My SP inserts a record if none exists and returns a 1 else returns 0, pretty simple I think.
SP
CREATE PROCEDURE [dbo].[User_UpdateMessage]
(
@UserId int = 0,
@UserId2 int = 0,
@Success bit = 0 OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS ( SELECT [UserIdFrom] FROM [dbo].[MessageUpdate] WHERE [UserIdFrom] = @UserId AND [UserIdTo] = @UserId2 )
BEGIN
INSERT INTO [dbo].[MessageUpdate] ([UserIdFrom], [UserIdTo])
VALUES (@UserId, @UserId2)
SELECT @Success = 1;
END
ELSE
SELECT @Success = 0;
END
In my code I am calling the SP:
// Output Parameter
System.Data.Objects.ObjectParameter paramSuccess1 =
new System.Data.Objects.ObjectParameter("Success", typeof(byte));
_Entity.User_UpdateMessage(id, userId, paramSuccess1);
It is failing while executing the SP with the following error:
The data reader returned by the store data provider does not have enough columns for the query requested
[UPDATE]
As I was writing this I solved the problem. In the Model designer, the return type should be none, I had it to return Byte.
An answer to this question could be further enhancements or changes.
To call a stored procedure with output parameters, you follow these steps: First, declare variables to hold the values returned by the output parameters. Second, use these variables in the stored procedure call.
Output parameters are the parameters that are fetched from the response of a service call. These are formatted according to the attributes you configure for the output before displaying on the device. The service parameters have a scope and data type attached to them.
A parameter whose value is sent out of the stored procedure/function module and back to the calling PL/SQL block is known as an output parameter. A variable, not a constant, must be used as an OUT parameter.
I too had the same problem, changed the return type to NONE instead of int32. Thanks saved me hours of debugging
you can use a 'select' statement in your stored procedure . it will solve the issue
Reference: http://codetunnel.com/blog/post/83/what-to-do-if-entity-framework-function-import-does-not-detect-any-columns-being-returned-by-your-stored-procedure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With