Hi all,
I'm using Entity Framework and MS SQL Server 2008. It seems that Entity Framework always round off decimal entity attribute to nearest integer which is really annoying. Have you seen this problem before and what's your solution? Thanks!
Hi all,
I'm using Entity Framework and MS SQL Server 2008. It seems that Entity Framework always round off decimal entity attribute to nearest integer which is really annoying. Have you seen this problem before and what's your solution? Thanks!
Without you providing your mapping classes and database schema I can only assume that in one of them you're using an Int or something that's set to zero decimal places of accuracy.
It would also be worth mentioning which version of EF (Entity Framework) you're using.
It shouldn't happen is the short answer.
Similar to what Timothy said, it's likely that one of the following is happening:
var
, the compiler could be inferring an integral type rather than a decimal typeAn example to clarify the second point:
var myNumber = 100; // myNumber will be an int
myNumber = myNumber / 3; // myNumber == 33 (an int)
Can you post some code to give us a better idea?
hi
i run into the same problem. I am using EF with SQL Server 2008 SP1. I use stored procedures to query some data. Another annoying thing is that if I create a function import for a stored procedure, EF supplies a function on the context class to call that sp, but for me, it does not. So I create my own function to call sp. In that functions I create EntityParameters by supplying DBType.Decimal. But this result in Precision and Scale set to 0. When I set to the correct numbers as my DB schema requires (3 and 1 btw), everything is ok.
zsolt