LinqConnect Professional Version 4.4.374 (14-Nov-2013) - MS SQL Server problem with SqlMethods.Between

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
AKRRKA
Posts: 198
Joined: Thu 26 Jan 2012 15:07
Location: Russia
Contact:

LinqConnect Professional Version 4.4.374 (14-Nov-2013) - MS SQL Server problem with SqlMethods.Between

Post by AKRRKA » Wed 04 Dec 2013 15:52

Using SqlMethods.Between() method in LINQ generates invalid query for SQL Server.

If a LINQ expression is constructed in the following way:

Code: Select all

 list = ctx.MyTable.Where(row => SqlMethods.Between(row.Id, 10, 20)).ToList();
it is evaluated by the underlying engine as the following SQL query: SELECT [t1].[Id] ...

Code: Select all

 FROM [MyTable] [t1]
 WHERE (([t1].[Id]) BETWEEN (10) AND (20)) <> 0;
which, in turn, gives the error "Incorrect syntax near '<'". The following query is correct, however:

Code: Select all

 SELECT [t1].[Id]
 FROM [MyTable] [t1]
 WHERE ([t1].[Id]) BETWEEN (10) AND (20);
It seems that the LinqConnect engine considers a BETWEEN expression value to be numeric rather than boolean, so it compares its value with zero, which is invalid for MS SQL Server.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LinqConnect Professional Version 4.4.374 (14-Nov-2013) - MS SQL Server problem with SqlMethods.Between

Post by MariiaI » Thu 05 Dec 2013 11:41

Thank you for the report on this. We have reproduced this issue. We will inform you when it is fixed.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LinqConnect Professional Version 4.4.374 (14-Nov-2013) - MS SQL Server problem with SqlMethods.Between

Post by MariiaI » Fri 13 Dec 2013 06:23

The bug related to the "Incorrect syntax near '<'" error when using SqlMethods.Between is fixed.
New build of LinqConnect 4.4.393 is available for download now!
It can be downloaded from http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=31&t=28506.

Post Reply