I cannot get sum () to return a decimal number, and it always returns an int64 truncating the decimal places. I have googled all day, but I canβt find a real job. I have a DB table called ProductPurchase with
QtyPurchased (integer) as well as UnitPurchasePrice Columns (money),
they map to a C # POCO object using NHibernate, where QtyPurchase is an int and UnitPurchasePrice is a decimal property.
I have the following HQL query where I want to get the total purchase amount for a given day:
select the amount (detail.QtyPurchased * detail.UnitPurchasePrice) from Domain.Entities.ProductPurchase AS detail where dateiff ("day", detail.PurchaseDate ,: trading_date) = 0
Now, for whatever reason, query.UniqueResult always returns an Int64 integer, decreasing decimal numbers, while the generated SQL obviously returns the correct decimal number. Can someone shed somelight on how to get this to return decimal numbers?
I noticed that if I use SQL (i.e. CreateSqlQuery), I can return the decimal. Is this a bug with Nhibernate?
Thanks heaps
Stephen Kuo
Steven kuo
source
share