我正在使用Oracle9i和NHibernate 3.1.0.4以及FluentNhibernate 1.2.0.712
NHibernate配置如下......
<property name="dialect">NHibernate.Dialect.Oracle9iDialect</property>
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="connection.connection_string">Data Source=ORA9TEST;User ID=NOPE;Password=NOPE;</property>
<property name="query.substitutions">true=1;false=0</property>
<property name="show_sql">true</property>
它生成此插入状态域
2012-08-10 16:33:36,380 [DEBUG] 15 NHibernate.SQL -
INSERT INTO FACT_Data (STime, subg_number, subg_index, measurement, Rj, InvalidSpec, data_uid, WrittenState, dept_id, specs_id, data_id) VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10);:p0 = 2/7/2012 12:49:57 AM [Type: DateTime (0)], :p1 = 103 [Type: Int32 (0)], :p2 = 0 [Type: Int32 (0)], :p3 = 30.346 [Type: Single (0)], :p4 = 0 [Type: Single (0)], :p5 = False [Type: Boolean (0)], :p6 = 0 [Type: Int32 (0)], :p7 = 0 [Type: Int32 (0)], :p8 = 2 [Type: Int32 (0)], :p9 = 45423 [Type: Int32 (0)], :p10 = 1178436 [Type: Int32 (0)]
列FACT_Data.Measurement类型为NUMBER(*,6)
当我读回该行时,而不是测量值为30.346,它是30.346001。如果没有额外的0.000001,我该怎么做才能正确存储我的单值?
请,谢谢
答案 0 :(得分:1)
如果需要这种精度,则应使用Decimal而不是Single。
您可以在此处找到有关浮点类型的更多信息:decimal vs double! - Which one should I use and when?