Page 1 of 1

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

Posted: Wed 04 Dec 2013 15:52
by AKRRKA
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.

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

Posted: Thu 05 Dec 2013 11:41
by MariiaI
Thank you for the report on this. We have reproduced this issue. We will inform you when it is fixed.

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

Posted: Fri 13 Dec 2013 06:23
by MariiaI
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.