Bug report - OracleDbType to DbType not consistant

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
daveoggy
Posts: 14
Joined: Fri 23 Jan 2009 18:15

Bug report - OracleDbType to DbType not consistant

Post by daveoggy » Mon 01 Nov 2010 18:31

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 03 Nov 2010 11:55

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();
            }
Last edited by Shalex on Thu 04 Nov 2010 12:30, edited 1 time in total.

daveoggy
Posts: 14
Joined: Fri 23 Jan 2009 18:15

Post by daveoggy » Wed 03 Nov 2010 15:59

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 04 Nov 2010 12:45

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)*.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 04 Nov 2010 12:54

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.

daveoggy
Posts: 14
Joined: Fri 23 Jan 2009 18:15

Post by daveoggy » Wed 02 Mar 2011 13:23

Did the planned NumberMappings feature for Entity Developer make it into the 6.x releases?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 03 Mar 2011 09:55

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.

Post Reply