2
votes

I am encoutering an issue with the decimal type and fluent nhibernate.

Here is my problem:

I have a class with a property:

public virtual decimal? Amount { get; set; }

In my mapping I have :

Map(x => x.Amount, "SOMETHING").Length(8).Precision(19).Scale(4).CustomSqlType("money"); 

The Nhibernate mapping I get is:

<property name="Amount" type="System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <column name="SOMETHING" length="8" sql-type="money" precision="19" scale="4" />
</property>

And what I get when I try to update this value with a sql server 2000 is:

Disallowed implicit conversion from data type varchar to data type money, table 'ANYTABLE, column '...'. Use the CONVERT function to run this query.

I am using MsSqlConfiguration.MsSql2000 to configure fluent hibernate and version 1.1.0.0 of fluent nhibernate.

Thanks for your help!

3

3 Answers

1
votes

I forgot to say, the problem is that in the request generated, I have:

UPDATE [A_TABLE]
SET    ....
   AMOUNT = '6118,2200' /* @p1_0 */,
   ....

and it should be

   AMOUNT = 6118.22

I am using NH3 as well.

0
votes

It works fine here, at least with NH 3.

How are you updating the value? Can you post the generated SQL?

0
votes

May be the length attribute is disturbing it. Take it away. Only strings have lengths.