Entity Framework rounds in two decimal numbers when everything is set for four decimal places

I’m trying to understand why Entity Framework 4 is rounded to two decimal places when the accuracy in the EF schema model and database is 4.

This is my schema definition for one of the decimal fields:

SellPrice specify a scale of 19.4

This is the definition of my database

CREATE TABLE OrderItems(
....
[SellPrice] [decimal](19, 4) NOT NULL,
....

When I execute my insert request after calculating the selling price of the product, I see that there is enough decimal

SellPrice shows lots of decimals

MiniProfiler shows my query and it shows that the value has a decimal value

DECLARE ...
        @15 Decimal = '100,54347826086956521739130435',
        ...

insert [dbo].[OrderItems](..., [SellPrice], ...)
values (..., @15, ....)
select [OrderItemId]
from [dbo].[OrderItems]
where @@ROWCOUNT > 0 and [OrderItemId] = scope_identity()

But when I look at Microsoft Sql Profiler, it SellPricerounds

exec sp_executesql N'insert [dbo].[OrderItems](..., [SellPrice], ...)
values (..., @15, ...)',
...,@15=100.54,...'

I find it difficult to find where the value is rounded.

+5
source share
1 answer

, SQL money, decimal decimal # , decimal SQL. , MSDN (http://msdn.microsoft.com/en-us/library/ms187746.aspx) TSQL decimal - ;

Transact-SQL , . , 12.345 5 3.

float real .

, , , . , money, , , EF, DB

+3

All Articles