This is a migrated thread and some comments may be shown as answers.

Query Translation Problem: Telerik Grid Control or SubSonic ORM?

2 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matthew
Top achievements
Rank 1
Matthew asked on 17 Dec 2010, 05:13 PM
Lately, I've been trying to get a view in my database to display in ASP.NET MVC. Recently, I decided to use the Telerik Grid control for ASP.NET MVC which is supposed to work well with anything IQueryable. Very advantageous when you want to do something like Filter on a Column. I've been using SubSonic 3.0.0.3 (rally25rs) as my ORM to access my Oracle 10g database.

By and large, the Telerik Grid control works great with SubSonic in SimpleRepository mode. It pulls back the view, pages, sorts, etc. But when I try to Filter on a Column using the "Starts With" option, I get the following Oracle error:

ORA-00920: invalid relational operator

Unwinding the Stack trace reveals that the Exception is being thrown in SubSonic.Core\DataProviders\DbDataProvider.cs    Line: 149    which
shows in the previous TRY block that the line " cmd.ExecuteReader() " is failing to execute properly. But this isn't the source of the problem. This is just an exception because the translated SQL is invalid.

Tracing thru the method "Translate(Expression expression)" in the "DbQueryProvider.cs" file, it's possible to watch the method translate the Expression Query into a SQL Query. When the method starts, the variable "expression" (of type:
Expression) is set to the following (I believe this comes directly from the Telerik control):

{Query(AssayPlate).Select(assayPlate => assayPlate)
            .Where(item => ((item.Assay ?? "").ToLower().StartsWith("abc") = True))
            .Count()}

and is transformed into the following, by the 3rd or 4th line in the method:

{Project(
  @"SELECT COUNT(*)
  FROM SomePlateView AS t0
  WHERE (CASE WHEN ((LOWER(COALESCE([t0].[Assay], ''))
         LIKE 'abc' + '%')) THEN 1 ELSE 0 END = 1)",
  A0.Column(""),
  p => Enumerable.Single(p)
)}

So I'm left wondering:

Is it the Telerik Grid control that's producing the poor Expression?
(this part here seems poorly constructed to me:StartsWith("abc") = True  ) Although it doesn't look that bad...

Or is there a bug in SubSonic that's not producing a proper SQL query translation?
The whole:  THEN 1 ELSE 0 END = 1   seems poorly translated to me.

Any ideas?

PS:  I'm using VS2008 Pro and C# / .NET 3.5 with MVC2 and the latest Telerik version (2010.3.1110.235)

2 Answers, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 17 Dec 2010, 07:23 PM
So I exported the table and imported it onto a different DB (SQLite) and tried the same thing and it works fine. This leads me to believe that the SubSonic ORM's support for Oracle 10g is still a bit "beta". Looks like I need to find a new ORM.  :-)
0
Manuel
Top achievements
Rank 1
answered on 14 Apr 2011, 05:11 PM
Hello. Do you perhaps know, where I can find the Parameter that tells me what language setting I am in?
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Manuel
Top achievements
Rank 1
Share this question
or