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

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

Postby 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.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

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

Postby 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

Postby 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.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)