Create a method in Entity Developer for a postgres function

Create a method in Entity Developer for a postgres function

Postby TonyV » Wed 12 Oct 2011 18:37

I have a stored function in my Postgres database that looks like this:

Code: Select all
CREATE OR REPLACE FUNCTION "CarSystem"."ScanLists"( OUT RowCount INT ) RETURNS INT
AS $$
...


When I run the Update Model from Database wizard I check off this function to be imported into the Model. But there's no method for it. If I try to right click and select "Create Method", or if I drag the function onto the design surface, I get the following error:

Code: Select all
Cannot create method for a storage function 'ScanLists' that can be composed. Only stored procedures can be mapped."


I want to be able to execute this stored proc from code through the entity model. How do I do this?

Tony
TonyV
 
Posts: 74
Joined: Wed 25 May 2011 15:03

I thought I had a fix for this, but it doesn't work

Postby TonyV » Mon 17 Oct 2011 19:49

As the title says, I thought I had a fix for this.

I edited the stored procedure's settings in the Entity Developer. I set the
return type to None. This allowed me to create a method for the stored procedure. But when I call the resulting method, I get the following error:

Code: Select all
function CarSystem.ScanLists(unknown) does not exist


I need to be able to call this stored function. Frankly, it doesn't need any arguments and it could return void. But when I set it up like that, Entity Developer doesn't like it for other reasons.

Should I just use the context's ExecuteFunction method to call this stored procedure and get rid of the argument & return type?

Tony
TonyV
 
Posts: 74
Joined: Wed 25 May 2011 15:03

Postby Shalex » Tue 18 Oct 2011 16:35

Please perform the following steps:
1. Drag the ScanLists function on the designer surface.
2. Go to the Moder Explorer->Model.Store. Edit the properties of this function: set Concealed to true.
3. Drag the function from the Model.Store to the designer surface.
4. Change the Return Type of the generated method (Model Explorer->Methods->ScanList->Properties > Return Type) to Int32.

EF doesn't allow to create method of context basing on the function (not stored procedure) which returns result. "Consealed" is our workaround for functions.
Shalex
Devart Team
 
Posts: 7774
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL