This project is read-only.

custom parameterless stored procedure

Aug 1, 2014 at 12:51 PM
Edited Aug 8, 2014 at 1:09 PM
Hi,I've created following procedure and I'm having troubles calling it.

The procedure as follows:
ALTER PROCEDURE UpdateWriters
AS
DECLARE @myField VarChar(50)
DECLARE @v_id INT
DECLARE @v_tmp INT 
BEGIN

DECLARE UpdateCursor CURSOR FOR SELECT autor.uID FROM dbo.autor
OPEN UpdateCursor
FETCH NEXT FROM UpdateCursor INTO @v_id
WHILE @@FETCH_STATUS = 0
    BEGIN
        SELECT @v_tmp = COUNT (*) FROM article WHERE article.autorID = @v_id
        UPDATE autor SET articleNumber= @v_tmp WHERE autor.uID = @v_id  
    FETCH NEXT FROM UpdateCursor INTO @v_id
    END
    CLOSE UpdateCursor
    DEALLOCATE UpdateCursor
end;
When I import procedure from DB it generates orange table and then validator bullies me into adding one field so it can be generated. I've added field - myField. Then it generates it's class into Entities folder.

I've tried both:
     using (var context = new myProjectEntities())
     {
           context.ExecuteFunction("UpdateWriters");
           //context.UpdateWriters();
     }
Yet both returns same error:
The data reader is incompatible with the specified 'myCompany.myProject.EFDAL.Entity.UpdateWriters'.  A member of the type, 'myField', does not have a corresponding column in the data reader with the same name.
What does this means? The procedure needs parameter? variable?

In manual it says that there can be parameterless procedure without return Value but it must be 'action' and ... well nothing more. There is example of calling bellow but real no explanation how to make it into said action. I've scouted throught properties and designer but there is simply no possibility of making the procedure 'action'.

So,... how can i get generator to make it a action or how I call it without it causing exceptions?
Any ideas?

EDIT:
I managed to make it work by creating the procedure in diagram and then using installer to create it in DB. It still returns the same exception, but the procedure is actualy executed on the server side.