Entity Framework and Infinity

  • Hi!

    Working in a project using Entity Framework (Code First)...

    Until now the project has been connected to a (generated) SQL Server Compact 4.0 database,

    but now we want to connect to a SQL Server (at least 2008R2 since we will use FILESTREAM...)

    Our problem right now is the possibility to enter Infinity values into REAL columns in the DB...

    It works in the SQL Server Compact but we have not been able to get it to work in 2008R2 or 2014

    The insertion of Infinity values is constructed by the Entity Framework (from using float.PositiveInfinity in C#) automatically so I mainly wonder if it at all is possible in a "real" database. Maybe there are some configurations possible to get it to work?

  • stpii (2/19/2015)


    Hi!

    Working in a project using Entity Framework (Code First)...

    Until now the project has been connected to a (generated) SQL Server Compact 4.0 database,

    but now we want to connect to a SQL Server (at least 2008R2 since we will use FILESTREAM...)

    Our problem right now is the possibility to enter Infinity values into REAL columns in the DB...

    It works in the SQL Server Compact but we have not been able to get it to work in 2008R2 or 2014

    The insertion of Infinity values is constructed by the Entity Framework (from using float.PositiveInfinity in C#) automatically so I mainly wonder if it at all is possible in a "real" database. Maybe there are some configurations possible to get it to work?

    https://connect.microsoft.com/SQLServer/feedback/details/239674/storing-ieee-754-floats-in-sql-server-2005-nan-infinity

    Lol varbinary(8) or downgrade to sql 2000. Next!

  • Thx for the link...

    I was hoping that some support for Infinity was added at least in SQL Server 2014...

    Strange that Microsoft Entity Framework even generates the code and that the Compact version works, since it is not considered OK for the "regular" SQL Server! 🙂

    Since Entity Framework generates the db interaction with the objects I suppose we have to change our approach to the whole idea then...

  • Yeah, even more so it used to work in 2000 (codebase for 2005...), I can sort of see their reasoning on NaN, but for the infinities, they seem to have an implied relationship with the non infinite number as far as sortability, plus, by definition real numbers are an approximation, so I would think instead of removing from 2000, they would simply add flags or 'SET' options that ask "how do you want to handle this".

    Lucky for me, I pretty much just count stuff at my job 🙂

    edit: they didn't actually remove them from 2000 LOL

  • stpii (2/19/2015)


    Hi!

    Working in a project using Entity Framework (Code First)...

    Until now the project has been connected to a (generated) SQL Server Compact 4.0 database,

    but now we want to connect to a SQL Server (at least 2008R2 since we will use FILESTREAM...)

    Our problem right now is the possibility to enter Infinity values into REAL columns in the DB...

    It works in the SQL Server Compact but we have not been able to get it to work in 2008R2 or 2014

    The insertion of Infinity values is constructed by the Entity Framework (from using float.PositiveInfinity in C#) automatically so I mainly wonder if it at all is possible in a "real" database. Maybe there are some configurations possible to get it to work?

    Out of curiosity, why targeting an SQL Server version that is out of mainstream support?

    😎

    Positive Infinity, being an imaginary value, is to my knowledge not supported in SQL Server (how could it?), it is interpreted within EF, so you have to look at EF for the functionality, not SQL Server. I'm quite intrigued by the though though$$$:w00t:

  • The customer system's server in use currently includes a 2008R2, but possibly this could be upgraded...

    Anyway... if SQL Servers ("real ones") don't support Infinity we will have to change the approach to one without such values for properties (that .NET supports and uses within EF without any issues...)

    Thanks for the info guys! Will stir up some feelings in the Project at the Scrum meeting tomorrow... 😀

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply