title: Pass table-type object as input parameter to Stored Procedure in Oracle from C#
body: <p>I have stored procedure which accepts table-type as input parameter.
  How to pass object from c# code?</p>
  
  <pre><code>create or replace TYPE CUSTOM_TYPE AS OBJECT 
  ( 
    attribute1 VARCHAR(10),
    attribute2 VARCHAR(10)
  );
  
  create or replace TYPE CUSTOM_TYPE_ARRAY AS TABLE OF CUSTOM_TYPE;
  
  PROCEDURE SP_TEST
  (
    P_TABLE_IN IN CUSTOM_TYPE_ARRAY,
    P_RESULT_OUT OUT SYS_REFCURSOR 
  ) AS 
  BEGIN
    OPEN P_RESULT_OUT FOR
      SELECT  ti.attribute1, ti.attribute2, ti.attribute3
      FROM  TABLE(P_TABLE_IN) ea inner join MYTABLE ti on ea.attribute1 = ti.attribute1 and ea.attribute2 = ti.attribute2;
  END SP_TEST;
  </code></pre>
  
  <p>And trying to add parameter like this:</p>
  
  <pre><code>var oracleParam = new OracleParameter();
  oracleParam.OracleDbType = OracleDbType.Array;
  oracleParam.Direction = ParameterDirection.Input;
  oracleParam.ParameterName = "P_TABLE_IN";
  oracleParam.Value = entities;
  oracleCommand.Parameters.Add(oracleParam); 
  </code></pre>
  
  <p>Where entities is an instance of custom collection of entities (with defined oracle attributes mapping)</p>
  
  <pre><code>public class EntityUdt
  {
      [OracleObjectMappingAttribute("attribute1")]
      public string attribute1 {get;set;}
      [OracleObjectMappingAttribute("attribute2")]
      public string attribute2 {get;set;}
  }
  </code></pre>
  
  <p>I followed <a href="http://appsjack.blogspot.co.uk/2010/09/pass-custom-udt-types-to-oracle-stored.html" rel="noreferrer">this guide</a> to define .net entity properly but still no luck with passing my list:</p>
  
  <blockquote>
    <p>System.InvalidOperationException was unhandled by user code<br>
    HResult=-2146233079<br>
    Message='EntityUdt::attribute1::OracleObjectMappingAttribute'
    cannot be set to an invalid value of 'attribute1'<br>
    Source=Oracle.DataAccess   StackTrace:
           at Oracle.DataAccess.Types.OracleUdtDescriptor.DescribeCustomType(Object
    customTypeFactory) </p>
  </blockquote>