其中.NET数据类型是最适合在映射的NHibernate的数量的Oracle数据类型? [英] Which .NET data type is best for mapping the NUMBER Oracle data type in NHibernate?

查看:345
本文介绍了其中.NET数据类型是最适合在映射的NHibernate的数量的Oracle数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了一些例子,其中小数在NHibernate的项目用于映射到Oracle整数列。现在,我使用 INT 在我的计划。

什么是小数超过 INT / ?是否有更好的表现?


解决方案

  

我见过小数代替INT /长在不同的例子。我只是试图理解为什么


这可能是因为.NET 小数和Oracle NUMBER 映射一个好一点比 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要能够重新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 using int and long in my program.

What are the advantages of decimal over int/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 Oracle NUMBER maps a bit better than long and NUMBER 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 used decimal.

decimal is certainly slower than int and long 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 use long if that that's what you're dealing with and then you should also let the table column definitions represent that. NUMBER(18,0) for long and so on.

The reason decimal maps a little better is that long is 64 bits and decimal is (kind of) 128 bits.

.NET

Type: decimal
Approximate Range: ±1.0 × 10^−28 to ±7.9 × 10^28
Precision: 28-29 significant digits

Type: 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 what NUMBER defaults to. I've never seen anyone do that and I would suppose it's a very rare need. Also BigInteger still wouldn't cut it since NUMBER can be of positive and negative infinity.

这篇关于其中.NET数据类型是最适合在映射的NHibernate的数量的Oracle数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆