Stack Exchange
Pass value of user-defined type as input parameter to stored procedure in Oracle from C#
I'm facing a problem that I can't map value object from C# to parameter procedure Oracle.
In Oracle I've got this structure:
CREATE OR REPLACE TYPE EMPMLOY AS OBJECT 
(
    FNAME VARCHAR2 (20),
    LNAME VARCHAR2 (20)
);

CREATE OR REPLACE PROCEDURE PROC_INSEMPLOY(P1 EMPMLOY)
IS
V_EMPLOY EMPMLOY;
BEGIN
    V_EMPLOY :=  P1;

   INSERT INTO MANAGE_EMPLYEE 
   VALUES (V_EMPLOY.FNAME, V_EMPLOY.LNAME);
END;

In C# code is like this:
[OracleCustomTypeMapping("EMPMLOY")]
public class Employ
{
    [OracleObjectMapping("FNAME")]
    public string Fname { get; set; }

    [OracleObjectMapping("LNAME")]
    public string Lname { get; set; }
}

using (var conn = new OracleConnection(cs))
{
    conn.Open();
    using (var cmd = conn.CreateCommand())
    {
        var employ = new Employ
        {
            Fname = "Thuy",
            Lname = "Tran"
        };

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "PROC_INSEMPLOY";

        var param = new OracleParameter
        {
            ParameterName = "P1",
            Direction = ParameterDirection.Input,
            OracleDbType = OracleDbType.Object,
            UdtTypeName = "EMPMLOY",
            Value = employ
        };

        cmd.Parameters.Add(param);
        cmd.ExecuteNonQuery();
    }
}

I get an error 

Invalid parameter binding parameter name

Please, help me fix this. Thanks in advance!

I had similar problems, but I was reading custom objects from an Oracle Advanced Queue.  To resolve my issues, I created an IOracleCustomTypeFactory as below:
[OracleCustomTypeMapping("EMPMLOY")]
public class EmployFactory : IOracleCustomTypeFactory
{
    public IOracleCustomType CreateObject()
    {
        return new Employ();
    }
}

Also I needed the following additions to the Class object too:
public class Employ : IOracleCustomType, INullable
{
    [OracleObjectMapping("FNAME")]
    public string Fname{ get; set; }

    [OracleObjectMapping("LNAME")]
    public string Lname{ get; set; }

    public void FromCustomObject(OracleConnection con, IntPtr pUdt)
    {
        OracleUdt.SetValue(con, pUdt, "FNAME", this.Fname);
        OracleUdt.SetValue(con, pUdt, "LNAME", this.Lname);
    }

    public void ToCustomObject(OracleConnection con, IntPtr pUdt)
    {
        this.Fname = OracleUdt.GetValue(con, pUdt, "FNAME").ToString();
        this.Lname = OracleUdt.GetValue(con, pUdt, "LNAME").ToString();
    }
}

