Executing a Pattern(Wildcard) search in OQL

3 posts, 1 answers
  1. Ashok Sridhar
    Ashok Sridhar avatar
    9 posts
    Member since:
    Dec 2006

    Posted 13 Apr 2009 Link to this post

    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. Answer
    Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 14 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. Ashok Sridhar
    Ashok Sridhar avatar
    9 posts
    Member since:
    Dec 2006

    Posted 14 Apr 2009 Link to this post

    Thanks Zoran.  That worked.
Back to Top