SQL Server command trying to use float(0,0)

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
michaeltmg
Posts: 3
Joined: Fri 31 Jul 2020 19:14

SQL Server command trying to use float(0,0)

Post by michaeltmg » Fri 31 Jul 2020 19:21

I'm evaluating LinqConnect for my company to use in moving an old project to .net core. I'm getting an error on this query

from u in db.user
where u.Created.Value.AddHours(-4) > date.Date
select u.ID

The error is "Line 3: Length or precision specification 0 is invalid."

I ran SQL Server Profiler to capture the SQL being run. It's

exec sp_executesql N'SELECT [t1].[ID]
FROM dbo.[user] [t1]
WHERE DATEADD(ms, (CAST(CONVERT(Float(0,0),@p0 * 3600000) AS Int)) % 86400000, DATEADD(day, (CAST(CONVERT(Float(0,0),@p0 * 3600000) AS Int)) / 86400000, [t1].[Created])) > @p1',N'@p0 float,@p1 datetime',@p0=-4,@p1='2020-07-31 18:18:50.047'

Float(0,0) isn't valid SQL Server syntax, so that's causing the above error. Is this expected behavior, a known error, or is something configured wrong?

michaeltmg
Posts: 3
Joined: Fri 31 Jul 2020 19:14

Re: SQL Server command trying to use float(0,0)

Post by michaeltmg » Fri 31 Jul 2020 20:44

Relatedly, a query of the form

db.User.Where(u => u.Created.Value - TimeSpan.FromDays(1)> date)

returns the error

Failed to convert parameter value from a TimeSpan to a DateTimeOffset.

It works under Linq to SQL

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: SQL Server command trying to use float(0,0)

Post by Shalex » Thu 06 Aug 2020 16:23

Thank you for your report. We have reproduced both issues and are investigating them. We will notify you about the result.

michaeltmg
Posts: 3
Joined: Fri 31 Jul 2020 19:14

Re: SQL Server command trying to use float(0,0)

Post by michaeltmg » Tue 18 Aug 2020 20:52

Just curious if there is any update on this, or if you could tell me where there might be one.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: SQL Server command trying to use float(0,0)

Post by Shalex » Tue 08 Sep 2020 09:58

* The bug with SQL generation of the explicit cast to FLOAT is fixed
* The bug with subtracting a TimeSpan value from the DATETIME column is fixed

We will notify you when the new public build of LinqConnect is available for download.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: SQL Server command trying to use float(0,0)

Post by Shalex » Mon 21 Sep 2020 15:11

New build of LinqConnect 4.9.2067 is available for download now: viewtopic.php?f=31&t=42245.

Post Reply