Search code examples
c#nhibernateormoracle11gllblgen

Decimal vs. int when using ORMs


I have been using ORM tools/code generators and I see that they prefer using decimal to int values when mapping columns to properties. Is there any advantage of using decimal ?

The column type in database is the default Number which created as Number(38, 0) I believe.


Solution

  • NUMBER is NUMBER(38), which has far larger possible range than int (Int32) (and much larger than long, too). double has different rounding semantics, so decimal is preferred to avoid errors and issues. If the ORM can guarantee that the data fits inside int, it might be happier to use int.