OQL query parameter issue

4 posts, 0 answers
  1. Peter Szintai
    Peter Szintai avatar
    28 posts
    Member since:
    Jul 2009

    Posted 28 Jun 2011 Link to this post

    Hi All,

    I wanted to execute the following query:

    Query<AbRightAccess> qaccessin =
        scope.GetOqlQuery<AbRightAccess>
        (
    "SELECT * FROM AbRightAccessExtent as RightAccess Where RightAccess.Deleted='0' and Exists User IN AbUserExtent : (User.UserId = RightAccess.UserId and User.CompId != $1 and User.Deleted = '0')");
    IList<AbRightAccess> laccessin = qaccessin.ExecuteList(AppVars.GetLong(
    "CompId")).ToList();

    In runtime I got an exception:
    System.ServiceModel.FaultException`1 was unhandled
      Message="The query does not accept parameters, but valid params were passed for query excecution"

    After this I have slightly modified the query:
    Query<AbRightAccess> qaccessin =
    scope.GetOqlQuery<AbRightAccess>
        (
    "SELECT * FROM AbRightAccessExtent as RightAccess Where RightAccess.Deleted=$2 and Exists User IN AbUserExtent : (User.UserId = RightAccess.UserId and User.CompId != $1 and User.Deleted = '0')");
    IList<AbRightAccess> laccessin = qaccessin.ExecuteList(AppVars.GetLong("CompId"), '0').ToList();

    I have changed the original RightAccess.Deleted = '0' condition to use parameter: RightAccess.Deleted=$2, the '0' character constant is added to the ExecuteList parameters.

    With these modifications the query works fine, but I don't understand, why do I have to add this "fake" parameter? Is it a bug, or feature and I interpret something badly about the OQL syntax?!

    Regards,

    Peter Szintai
  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 28 Jun 2011 Link to this post

    Hello Peter Szintai,
    This is a bug in our OQL implementation. Looks like even your second attempt is not working, the generated SQL is wrong.
    Is it possible for you to use Linq instead, or are you bound to .NET 2.0?

    Greetings,
    Jan Blessenohl
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  3. DevCraft banner
  4. Peter Szintai
    Peter Szintai avatar
    28 posts
    Member since:
    Jul 2009

    Posted 28 Jun 2011 Link to this post

    Dear Jan,

    we use .NET 3.5 or 4.0, so, it is not problem to use LINQ instead.

    but, until now we used the GetOqlQuery/ExecuteList methods to get the needed information from the database.
    Does your answer mean, that it is recommended to rewrite every existing code to LINQ based?

    Regards,

    Peter
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 29 Jun 2011 Link to this post

    Hi Peter Szintai,
    Nono, you should stay with OQL, we will not break it, but we will also try to not do complicated bug fixes if it works with linq. If you can change only this query it would help us two.

    All the best,
    Jan Blessenohl
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Back to Top