Page 1 of 1

Adding function return Composite Type in Devart Entity Model

Posted: Wed 05 Jan 2011 00:34
by pgBest
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.

Posted: Tue 11 Jan 2011 13:35
by AndreyR
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.

Posted: Mon 11 Jul 2011 12:50
by AndreyR
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.

Posted: Mon 11 Jul 2011 13:21
by plazmdk
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"

Posted: Wed 13 Jul 2011 08:19
by AndreyR
Plazmdk, thank you for sharing the solution.