Cross-database (Oracle/MSSQL) numeric fields question

Posts   
 
    
Innes avatar
Innes
User
Posts: 45
Joined: 18-Jun-2004
# Posted on: 24-Jun-2005 17:53:44   

Im using LLBLGEN against both Oracle and SQLServer.

In my databases, I have a lot of numeric fields like this:

**SQL Server DDL: ACTION_ID numeric(10, 0), Oracle DDL: ACTION_ID NUMBER(10), **

When generated, the corresponding entity has a property ActionId of type:

SQL Server DAL generic project: decimal Oracle DAL generic project: long

Of course, I have to pick one generic DAL to use (I use the Oracle one), and when I try to access a SQLServer database, the code throws an exception accessing (eg) the ActionId property.

At the moment, I am manually subclassing all entities and writing my own property accessors that use the 'Convert.ChangeType' function to convert to long.

I'm in control of the details of this database, so I have leeway to mess around with the exact details of the field type, if this will make it possible to arrive at values that support a similar range of numbers in both databases, and result in the same .NET type of the corresponding property. Does anyone know what scale/precision/dbtype I should use to arrive at the same property type for both databases?

Even if the field types used dont support exactly the same range, that wouldnt be a big deal.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 24-Jun-2005 18:10:24   

numeric in SqlServer == decimal, always.

Which type do you prefer: the decimal type or the long type? I think you just want to store precision 10, 0 scale values, correct? Then, define on SqlServer a bigint field and on oracle NUMBER(10,0). This will both result in a long field. simple_smile

In the upcoming upgrade it should be possible to specify the .net type for a given db type (with precision /scale/length) and a converter object.

Frans Bouma | Lead developer LLBLGen Pro
Innes avatar
Innes
User
Posts: 45
Joined: 18-Jun-2004
# Posted on: 25-Jun-2005 15:32:39   

Thanks - that's allowed me to rip out a lot of fairly tedious code. simple_smile