Adding function return Composite Type in Devart Entity Model

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
pgBest
Posts: 1
Joined: Tue 04 Jan 2011 23:55

Adding function return Composite Type in Devart Entity Model

Post by pgBest » Wed 05 Jan 2011 00:34

When adding a function which returns Composite Type in Devart Entity Model it fails. For example adding a get_emps() function returns setof emp, a composite type created automatically when emp table is created, through "Update From Database Wizard" it fails. No codes is generated in DataModel.Designer.cs but the following error message
// Custom tool 'DevartEfGenerator' failed.
// - The Type emp is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.

In ADO.Net Entity Data Model there is function import feature as the following link http://msdn.microsoft.com/en-us/library/bb896231.aspx.
Is there similar feature in Devart Entity Model for Postgres?

Thanks for your help.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 11 Jan 2011 13:35

Composite types do not have any key defined, so there is no possibility to use them as a collection return type in entity model (like Function Import in SQL Server).
Use the following workaround:
1. Add a new Defining Query corresponding to the composite type of the Store part of the model (you can do this in Model Explorer).
2. Drag this new entity to the designer. A new entity will appear there.
3. Drag the procedure returning the set of composite type to the designer from Database Explorer. The error you have already reported will be there.
4. Set the Composable property to false and the Concealed Function property to true.
5. Drag the function to the designer. Say "Yes" when asked about obtaining metadata.
6. Delete the generated complex type and set Return Type of the method to the entity that you have created from defining query.
I have tried this approach and it works using the latest 5.0.69 build of dotConnect for PostgreSQL.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 11 Jul 2011 12:50

Plazmdk, does your function return a set of records? If so, please upgrade to the latest 5.30.185 build - we have fixed a similar error in it.
Please notify us if the error persists.

plazmdk
Posts: 1
Joined: Mon 11 Jul 2011 07:47

Post by plazmdk » Mon 11 Jul 2011 13:21

Yes, it returns a set of records, with the newest version I get an error message that such a function needs a list of it columns,

Any how, it is not a problem if i create a custom type in postgresql first and uses this as the return type: "setof customType"

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 13 Jul 2011 08:19

Plazmdk, thank you for sharing the solution.

Post Reply