Import function with Out/InOut parameters

Import function with Out/InOut parameters

Postby Tetranos » Wed 14 Nov 2012 16:33

Hi,

It seems that it is not possible to import functions with Out or InOut parameters.
Those functions do not appear in the drop down list of the "Add Function Import" dialog.

Does anyone knows why?

Thanks
Tetranos
 
Posts: 4
Joined: Mon 29 Oct 2012 17:09

Re: Import function with Out/InOut parameters

Postby Shalex » Thu 15 Nov 2012 12:48

We recommend using Entity Developer (the Devart Entity Model template, *.edml) which is adjusted for working with PostgreSQL.
Tips:
1. After adding the function to the *.edml model, select it in Tools > Entity Developer > Model Explorer (the Store part), press F4 and set its Concealed Function property to True (in this case Entity Framework considers this function will be treated as a stored procedure which does not return a value). After this, you can add the method to the conceptual part of the model.
2. Be aware that ref cursor in PostgreSQL can be returned only within opened transaction. An example for ObjectContext:
Code: Select all
using (MyEntities context = new MyEntities()) {
    var connection = (context.Connection as System.Data.EntityClient.EntityConnection).StoreConnection;
    connection.Open();
    var transaction = connection.BeginTransaction();
    result = context.MyMethod();
    ...
}
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Import function with Out/InOut parameters

Postby Tetranos » Thu 15 Nov 2012 14:35

I've tried that but the resulting CSDL contains a DevArt namespace xmlns:ed="http://devart.com/schemas/EntityDeveloper/1.0" that is used in the <FunctionImport>.

We need to share a same CSDL for 4 databases engines (MSSQL, MySQL, Oracle, PostgreSQL) and because we do not use DevArt for MSSQL I'm not sure thie will work.
Tetranos
 
Posts: 4
Joined: Mon 29 Oct 2012 17:09

Re: Import function with Out/InOut parameters

Postby Shalex » Wed 21 Nov 2012 09:42

Tetranos wrote:We need to share a same CSDL for 4 databases engines (MSSQL, MySQL, Oracle, PostgreSQL)

You can do that.

Tetranos wrote:I've tried that but the resulting CSDL contains a DevArt namespace xmlns:ed="http://devart.com/schemas/EntityDeveloper/1.0" that is used in the <FunctionImport>.

You can use the CSDL, which is created for SQL Server, for all databases.

An example of such approach is available at http://www.devart.com/dotconnect/efquerysamples.html. Also please take into account that Oracle/MySQL/PostgreSQL have limitations/differences in behaviour comparing to SQL Server. Some of them are listed here: http://www.infoq.com/articles/multiple-databases.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL