T数据类型是最适合在映射的NHibernate的数量的Oracl

T数据类型是最适合在映射的NHibernate的数量的Oracl

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

问题描述

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

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


解决方案

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

Oracle

NUMBER defaults to 38 significant digits and scale 0 (integer).

Microsoft is aware of the problem and notes

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数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 15:14