jonpryor / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
0 stars 0 forks source link

DbMetal InvalidCastException with odp.net #263

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Ran DbMetal with command line:

dbmetal /provider:OracleODP /conn "Data Source=xxxx;User 
Id=xxxx;Password=xxxx;" /code:File.cs /database=xxxx

and got the error:

DbMetal: System.InvalidCastException: Specified cast is not valid.
   at Oracle.DataAccess.Client.OracleDataReader.GetInt32(Int32 i)
   at DbLinq.Oracle.OracleSchemaLoader.<ReadConstraints>b__1(IDataReader r) in z:\Development\DbLinq-0.20.1\src\DbLinq.Oracle\OracleSchemaLoader.Constraints.cs:line 110

What appears to be happening is that the query to get all constraints is trying 
to convert the column position (from all_cons_columns) into an integer using 
GetInt32(). The problem is that the position column is actually a number type, 
and is being returned as a decimal causing the casting error.

Original issue reported on code.google.com by Alan.2.W...@gmail.com on 30 Jun 2010 at 2:01

GoogleCodeExporter commented 9 years ago
The call has to be GetDecimal() to work with Oracle ODB. you also have to 
correct DbTransaction to IDbTransaction / DbConnection to IDbConnection because 
Oracle ODB derivate from System.Data.IDb* classes. I had to do this today 
because of a switch on .net 4

Original comment by mabuni...@gmail.com on 30 Jun 2010 at 5:03