Page 1 of 1

Bug report - OracleDbType to DbType not consistant

Posted: Mon 01 Nov 2010 18:31
by daveoggy
I have a column in my table defined as:

Code: Select all

"TREE_LEVEL"      NUMBER(10,0) DEFAULT 1
As far as I can tell NUMBER should map to DbType Int64.

When I create an entity model containing this table, the entity does indeed have a TREE_LEVEL property with of type Int64.

When I manually fetch the data using an OracleDataReader the DbType of the column is double.

I can provide code samples if reproducing this is a problem.

Posted: Wed 03 Nov 2010 11:55
by Shalex
This is a designed behaviour.

Here is a link to Entity Framework Data Type Mapping: http://www.devart.com/dotconnect/oracle ... pping.html.

Mappings between OracleDbType values, Oracle data types, Microsoft .NET Framework types are available in our documentation at http://www.devart.com/dotconnect/oracle ... bType.html.

As a workaround, you can implement your own connection level mapping using the OracleConnection.NumberMappings property (description of the NumberMapping constructor is here):

Code: Select all

          //CREATE TABLE NUMERIC_TABLE (
          //   ID NUMBER,
          //   N_10_COLUMN NUMBER(10,0));
          //insert into NUMERIC_TABLE values (1, 100);

            using (OracleConnection conn = new OracleConnection()) {
                conn.ConnectionString = "server=****;uid=scott;pwd=tiger;";
                
                //the next 2 lines make a mapping rule
                conn.NumberMappings = new NumberMappingCollection();
                conn.NumberMappings.Add(new NumberMapping(OracleNumberType.Integer, 10, 18, typeof(Int64)));
                
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = "select * from NUMERIC_TABLE";
                conn.Open();
                OracleDataReader reader = cmd.ExecuteReader();
                reader.Read();
                Console.WriteLine(reader["N_10_COLUMN"].GetType());
                Console.ReadLine();
            }

Posted: Wed 03 Nov 2010 15:59
by daveoggy
Thanks for the workaround! But isn't there still a discrepency?

From the link you gave

"NUMBER(x, 0)..NUMBER(x, 15)* double Double System.Double"

My NUMBER(10, 0) is being identified - incorrectly - as Int64 when building entities and double when using a datareader.

Posted: Thu 04 Nov 2010 12:45
by Shalex
daveoggy wrote:But isn't there still a discrepency?

From the link you gave

"NUMBER(x, 0)..NUMBER(x, 15)* double Double System.Double"

My NUMBER(10, 0) is being identified - incorrectly - as Int64 when building entities and double when using a datareader.
Thank you for your correction. We will change NUMBER(x, 0)..NUMBER(x, 15)* --> NUMBER(x, 1)..NUMBER(x, 15)*.

Posted: Thu 04 Nov 2010 12:54
by Shalex
I have also edited my post with the sample: OracleNumberType.Number --> OracleNumberType.Integer.
Here is a description of the OracleNumberType members:
OracleNumberType.Integer - Corresponds to the NUMBER Oracle type with the scale = 0.
OracleNumberType.Number - Corresponds to the NUMBER Oracle type with the scale != 0.
OracleNumberType.Float - Corresponds to the FLOAT Oracle type.

We are planning to implement the NumberMappings feature in Entity Developer in the future.

Posted: Wed 02 Mar 2011 13:23
by daveoggy
Did the planned NumberMappings feature for Entity Developer make it into the 6.x releases?

Posted: Thu 03 Mar 2011 09:55
by AndreyR
No, this functionality is not implemented yet.
We are unable to provide any timeframe for this feature to be added in the Entity Developer design time.
However, you can provide Number Mappings in the Entity Developer connection string, and the Oracle numbers will be obtained in accordance with the specified mappings in runtime.