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: 2
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: 2
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: 8981
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.

Post Reply