This is a migrated thread and some comments may be shown as answers.
Telerik.OpenAccess.RT.sql.SQLException: Incorrect syntax near
3 Answers 38 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mateusz
Top achievements
Rank 1
Mateusz asked on 16 Dec 2014, 04:09 PM
Hi all,

I am using Telerik UI for ASP.NET MVC (2014.2.716.545) and OpenAccess ORM (2014.2.711.1) in my work.
ExpressionBuilder is used for build an expression from filter descriptors (from datasourcerequest).
Everything works fine, but only if I don't use boolean filter in grid.
When using this filter, I get an exception:
[DataStoreException: Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Incorrect syntax near '='. ---> System.Data.SqlClient.SqlException: Incorrect syntax near '='.

With Entity Framework, error don't occurs.
I spend some time for investigation, and it seems problem is in the generated query.
In query is
WHERE ((CASE WHEN a.[Id] IS NOT NULL THEN  (CASE WHEN a.[Window] <> 0 THEN 1 ELSE 0 END)  ELSE 0 END)  = 1)  = (1=0)
instead
WHERE ((CASE WHEN a.[Id] IS NOT NULL THEN  (CASE WHEN a.[Window] <> 0 THEN 1 ELSE 0 END)  ELSE 0 END)  = 0)

3 Answers, 1 is accepted

Sort by
0
Mateusz
Top achievements
Rank 1
answered on 16 Dec 2014, 04:29 PM
My c# function:

01.public static IQueryable<T> ApplyFiltering<T>(this IQueryable<T> data,
02.           IList<IFilterDescriptor> filterDescriptors)
03.        {
04.            if (filterDescriptors != null && filterDescriptors.Any())
05.            {
06.                data = data.Where(ExpressionBuilder.Expression<T>(filterDescriptors));
07.            }
08.            return data;
09.        }
0
Accepted
Thomas
Telerik team
answered on 18 Dec 2014, 09:08 AM
Hello Mateusz,

this looks like to be an issue. There seems to be an explicit comparison with a bool value of true/false at the end, and this causes a push to the server (1=0 expression), generating invalid SQL.
As a workaround, you could eliminate == false as well as == true from the generated expression via LINQ expression manipulation, but this might a bit of effort for you.
I've filed a bug entry for this issue, but I cannot promise any fix date for the moment.

Thanks for reporting this issue back with us.

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Mateusz
Top achievements
Rank 1
answered on 18 Dec 2014, 10:51 AM
Hello Thomas,

Thanks for response.
I made some changes in my code, and now I set checkForNull parameter to false when property is not null.
It seems, everything works fine.
Tags
LINQ (LINQ specific questions)
Asked by
Mateusz
Top achievements
Rank 1
Answers by
Mateusz
Top achievements
Rank 1
Thomas
Telerik team
Share this question
or