Calling Stored Procedure with scalar return value from EF
Posted: Wed 24 Jun 2009 12:53
Hi,
we want to use sequences to get the value for the id column before calling the Create()-Method.
To get these we wrote an StoredProcedure:(To keep it simple we use varchar during our first steps)
This works fine.
We stuck when trying to call this Procedure from EFWe have troubles with the return value of the Procedure. Since we return a scalar value (NEXTID), EF fails?!
We also tried to create an custom object in C# with one property "NEXTID" and the correspondent mapping in edmx - this ends up with
the error message "The data reader is incompatible with the specified 'Model.PrimaryKey'. A member of the type, 'NEXTID', does not have a corresponding column in the data reader with the same name.".
So, is there a possibility to access this stored procedure with EF?
Thanks!
we want to use sequences to get the value for the id column before calling the Create()-Method.
To get these we wrote an StoredProcedure:
Code: Select all
create or replace PROCEDURE GetNextPrimaryKey (
sequenceName IN VARCHAR2,
NEXTID OUT VARCHAR2
) AS v_sequence VARCHAR2(30);
BEGIN
SELECT OBJECT_NAME INTO v_sequence FROM USER_OBJECTS
WHERE OBJECT_NAME = UPPER(sequenceName) AND OBJECT_TYPE = 'SEQUENCE';
EXECUTE IMMEDIATE 'SELECT '|| v_sequence ||'.NEXTVAL from dual' INTO NEXTID;
END GetNextPrimaryKey;
This works fine.
We stuck when trying to call this Procedure from EF
Code: Select all
context.GETNEXTPRIMARYKEY("SEQ_ANWENDER");
We also tried to create an custom object in C# with one property "NEXTID" and the correspondent mapping in edmx - this ends up with
the error message "The data reader is incompatible with the specified 'Model.PrimaryKey'. A member of the type, 'NEXTID', does not have a corresponding column in the data reader with the same name.".
So, is there a possibility to access this stored procedure with EF?
Thanks!