c# - Specified Cast not Valid error using Nhibernate -


using nhibernate, visual studio 2010, c#.

i having problem converting decimal? type. code gives

specified cast not valid error

and fails on .uniqueresult<> line.

following code.

private decimal? getcostvaluefromquery(string query, itempricecontext item) {     var session = activerecordmediator.getsessionfactoryholder()                                       .createsession(typeof(object));     return session.createsqlquery(string.format(query, item.itemcode))                   .uniqueresult<decimal?>(); } 

the result of sql query 62.3891005516052

i suspect result has lot of decimal places , hence fails.

any suggestions how round result or reduce result such supported?

use whatever rounding, truncating etc. need in select-part of sql query.

but should check actual return type of sql query is. decimal?


Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -