This article describes my problem. I have several properties that are calculated. They are typed as decimal (9.2) in SQL Server and decimal numbers in my C # classes. Example problem:
- Object loaded with property value 14.9
- The calculation is performed, and the property value changes to 14.90393
- When a session is cleared, NHibernate issues an update because the property is dirty
- Since the database field is decimal (9.2), the stored value does not change
Basically, a phantom update is issued every time this object loads. I donβt want to truncate calculations in my business objects, because it tightly links them to the database, and I donβt want to lose accuracy in other calculations. I tried to set the scale and precision or CustomType ("Decimal (9,2)") in the mapping file, but this seems to only affect the creation of the circuit.
My only reasonable option seems to be creating an IUserType implementation to handle this. Is there a better solution?
source share