Telerik.OpenAccess.RT.sql.SQLException: Incorrect syntax near

4 posts, 1 answers
  1. Mateusz
    Mateusz avatar
    3 posts
    Member since:
    May 2014

    Posted 16 Dec 2014 Link to this post

    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)
  2. Mateusz
    Mateusz avatar
    3 posts
    Member since:
    May 2014

    Posted 16 Dec 2014 in reply to Mateusz Link to this post

    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.        }
  3. DevCraft banner
  4. Answer
    Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 18 Dec 2014 Link to this post

    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.
     
  5. Mateusz
    Mateusz avatar
    3 posts
    Member since:
    May 2014

    Posted 18 Dec 2014 in reply to Thomas Link to this post

    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.
Back to Top