SQL Server Linq Average function on integer field only returns truncated integer value

Description

On Sql Server 2008 the following query will only return the truncated integer part (Age is a integer field):

session.Query<Person>.Average(p => p.Age)

Person Age Value (1, 2, 2)

Results:
SQL Server 2008: 1.0
SQLite: 1.666666666666...
Linq to Objects: 1.666666666666...

The SQL Server documentation confirms this behaviour. Therefore for SQL Server 2008 it would be necessary to cast the integer value into a float value before calculating the average.

Environment

None

Activity

Show:

Oskar Berggren May 30, 2012 at 6:31 PM

Closing issues fixed in 3.3.1.CR1.

Oskar Berggren March 10, 2012 at 9:08 PM

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?

Created November 26, 2010 at 5:35 AM
Updated May 10, 2013 at 12:44 AM
Resolved May 10, 2013 at 12:44 AM
Who's Looking?