Bug #58552 Round in Linq to Entities ignore decimalplacey value
Submitted: 29 Nov 2010 9:42 Modified: 19 May 2011 20:14
Reporter: Chris Gehrmann Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S1 (Critical)
Version:6.3.5, trunk OS:Windows
Assigned to: Julio Casal CPU Architecture:Any
Tags: .net, entity framework, linq, round

[29 Nov 2010 9:42] Chris Gehrmann
in a Linq 2 Entities Query, the function Math.Round(double x, int decimalplaces)
ignores the decimalplaces value and truncates the number.

The function doesen't throw any error, but if look in the logfile on the server,
you can see that the query doesn't contains any value for decimal places.

How to repeat:
short sample

from x in table
select Math.Round(x.doublevalue, 2);

--> select Round(x.doublevalue) from table
[30 Nov 2010 7:59] Tonci Grgin
Hi Chris and thanks for your report.

I see two definitions for ROUND:
    <!-- Round -->
    <Function Name="ROUND" BuiltIn="true">
      <ReturnType Type="Double" />
      <Parameter Name="x" Type="Double" Mode="In"/>

    <Function Name="ROUND" BuiltIn="true">
      <ReturnType Type="Double" />
      <Parameter Name="x" Type="Double" Mode="In"/>
      <Parameter Name="d" Type="Int32" Mode="In"/>

Are you sure you're calling the right one? If you are, please attach complete test case so I can check.
[30 Nov 2010 9:26] Chris Gehrmann
i have testet both versions for rounding. it seems that both versions uses the function without decimalplace value.

i have added a small testproject and a sample datebase, which i have used for testeting.
[1 Dec 2010 16:13] Tonci Grgin
Chris, verified just as described using test case attached.

  o Win7Ux64, VS2010Premium, .NET FW 4.0.30319
  o Remote MySQL server 5.1.31x64 on OpenSolaris host.

Test case output:
Double: 24.34534,       24,     24
Flaot:  32.2342,        32,     32
Double: 1,      1,      1
Flaot:  3,      3,      3
Double: 3.53456346346346,       4,      4
Flaot:  4.23232,        4,      4
[19 May 2011 20:14] Julio Casal
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

[19 May 2011 20:17] Julio Casal
Fixed in 6.3.7 and 6.4.1