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.