其中.NET数据类型是最适合在映射的NHibernate的数量的Oracle数据类型? [英] Which .NET data type is best for mapping the NUMBER Oracle data type in NHibernate?
问题描述
我已经看到了一些例子,其中小数
在NHibernate的项目用于映射到Oracle整数列。现在,我使用 INT
和长
在我的计划。
什么是小数
超过 INT
/ 长$ C $的优势C>?是否有更好的表现?
我见过小数代替INT /长在不同的例子。我只是试图理解为什么
块引用>这可能是因为.NET
小数
和OracleNUMBER
的映射一个好一点比长
和NUMBER
键,它也给你更大的灵活性。如果您在后期添加的比例的在Oracle列,那么你就不必改变数据类型,如果你已经使用小数
。
小数
肯定是慢INT
和长
由于后两种在硬件支持。这就是说,你要紧缩一些数据严重金额为它做任何区别。我仍然认为,你应该使用长
如果这是你处理什么用,然后你也应该让表列的定义重新present这一点。NUMBER(18,0)
为长
等。究其原因
小数
映射好一点的是,长
为64位和十进制
是(种)128位。.NET
类型:小数结果
大致范围:±1.0×10 ^ -28到±7.9×10 ^ 28结果
precision:28-29显著数字
类型:长结果
范围:-9,223,372,036,854,775,808到9,223,372,036,854,775,807结果
precision:18(19 ULONG)显著数字
块引用>
块引用>的Oracle
NUMBER
defaults 38显著数字和刻度0(整数)。
类型: NUMBER 结果
范围:+ - 1×10 ^ -130至9.99 ... 9×10 ^ 125结果
precision:38显著数字
块引用>
块引用>微软也意识到href=\"http://msdn.microsoft.com/en-us/library/yk72thhd.aspx\">说明问题和
此数据类型是为一个别名
数(38)的数据类型,并且被设计
使得OracleDataReader返回
System.Decimal或OracleNumber,而不是
的整数值。使用.NET
Framework数据类型可以导致
溢出。
块引用>细想它实际需要的<$c$c>BigInteger$c$c>要能够重新present相同数量的显著数字,以什么
NUMBER
默认。我从来没有见过任何人这样做,我会想这是一个非常难得的需要。此外的BigInteger
还是不会削减它,因为NUMBER
可正,负无穷大的。I've seen some examples in which
decimal
is used in NHibernate projects for mapping to whole number columns in Oracle. Right now I'm usingint
andlong
in my program.What are the advantages of
decimal
overint
/long
? Does it perform better?解决方案I've seen decimal used instead of int/long in various examples. I'm just trying to understand why
That's probably because .NET
decimal
and OracleNUMBER
maps a bit better thanlong
andNUMBER
and it also gives you more flexibility. If you at a later stage add a scale in the Oracle column then you wouldn't have to change datatype if you already useddecimal
.
decimal
is certainly slower thanint
andlong
since the later two are supported in hardware. That said, you have to crunch some serious amount of data for it to make any difference. I still think that you should uselong
if that that's what you're dealing with and then you should also let the table column definitions represent that.NUMBER(18,0)
forlong
and so on.The reason
decimal
maps a little better is thatlong
is 64 bits anddecimal
is (kind of) 128 bits..NET
Type: decimal
Approximate Range: ±1.0 × 10^−28 to ±7.9 × 10^28
Precision: 28-29 significant digitsType: long
Range: –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Precision: 18 (19 for ulong) significant digits
Oracle
NUMBER
defaults to 38 significant digits and scale 0 (integer).Type: NUMBER
Range: +- 1 x 10^-130 to 9.99...9 x 10^125
Precision: 38 significant digits
Microsoft is aware of the problem and notes
This data type is an alias for the NUMBER(38) data type, and is designed so that the OracleDataReader returns a System.Decimal or OracleNumber instead of an integer value. Using the .NET Framework data type can cause an overflow.
Come to think of it you actually need
BigInteger
to be able to represent the same number of significant digits as to whatNUMBER
defaults to. I've never seen anyone do that and I would suppose it's a very rare need. AlsoBigInteger
still wouldn't cut it sinceNUMBER
can be of positive and negative infinity.这篇关于其中.NET数据类型是最适合在映射的NHibernate的数量的Oracle数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!