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

Executing a Pattern(Wildcard) search in OQL

2 Answers 186 Views
OQL (OQL specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ashok Sridhar
Top achievements
Rank 1
Ashok Sridhar asked on 13 Apr 2009, 06:39 PM
Hi,

I have an Employer table and a corresponding object.

When I try to do a wildcard search in OQL like

scope.GetOqlQuery<Employer>("SELECT emp FROM EmployerExtent AS emp WHERE emp.EmployerName LIKE \"*$1*\" ").ExecuteList("Ashok");

I get an error saying "expected 0 parameters received 1"

If I change the like to an equals without any wildcard it works fine.  I even tried the GetOqlQuery().Execute() method with the same error.  So generic or not, it throws an error.  What could be the issue?


2 Answers, 1 is accepted

Sort by
0
Accepted
Zoran
Telerik team
answered on 14 Apr 2009, 07:09 AM
Hi Ashok Sridhar,

There is a slight change in the format of your OQL query that should be done. When using parameters quotation marks are not required as part of the query and also the "*" characters should be part of the parameter passed when using wildcards.
Here is a modified version of your query that should not do any problems when executed:

scope.GetOqlQuery<Employer>("SELECT emp FROM EmployerExtent AS emp WHERE emp.EmployerName LIKE $1 ").ExecuteList("*Ashok*");

Best wishes,
Zoran
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Ashok Sridhar
Top achievements
Rank 1
answered on 14 Apr 2009, 10:27 PM
Thanks Zoran.  That worked.
Tags
OQL (OQL specific questions)
Asked by
Ashok Sridhar
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Ashok Sridhar
Top achievements
Rank 1
Share this question
or