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)