Uploaded image for project: 'NHibernate [Moved to GitHub]'
  1. NH-2429

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.0.CR1
    • Fix Version/s: 3.3.0.CR1
    • Component/s: Linq Provider
    • Labels:
      None
    • Sprint:

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              thohot Thomas Hotz
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Who's Looking?