I am required to map an Oracle Object type in my c# application. There are tons of examples online, both here and other sites/blogs, but all of them include using a stored procedure, which I shouldn't do.
I have been searching for the past two days and the closest I got was an article on docs.oracle.com, but it is without an example.
Can anyone, please, give an example of how this could be achieved?
I am using Oracle.DataAccess class for communication with my database and a simple UDT given below:
create or replace
TYPE "MYNUMBER_TYPE" AS OBJECT (
MyNumber NUMBER(13)
)
INSTANTIABLE NOT FINAL;
If you want to execute PL/SQL you can do something like the following. This is mighty enough to tear the world domination itself. Almost.
Note, this is not tested, as I do not have a Oracle DB here. However I am using this approach in one of my current projects.
EDIT 3 aka answer to you comment:
For usage of the IOracleCustomType-Interface: Again, I couldn't test it as I still don't have access to an Oracle database. However, let's do some magic.
Step 1: Create a custom type in your C# code which inherits from IOracleCustomType:
Then for each class member you have to specify the Oracle pendant. In the following the name "MyNumber" comes from the custom type specification in your question.
Furthermore you have to override the methods FromCustomObject and ToCustomObject:
Step 2: Create the custom type in Database which you already did. So I will not repeat it here.
Step 3: Now we are set up. Let's try it: