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

OQL query parameter issue

3 Answers 86 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.
Peter Szintai
Top achievements
Rank 1
Peter Szintai asked on 28 Jun 2011, 03:50 PM
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

3 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 28 Jun 2011, 05:52 PM
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.
0
Peter Szintai
Top achievements
Rank 1
answered on 28 Jun 2011, 06:34 PM
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
0
Jan Blessenohl
Telerik team
answered on 29 Jun 2011, 09:26 AM
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.
Tags
OQL (OQL specific questions)
Asked by
Peter Szintai
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Peter Szintai
Top achievements
Rank 1
Share this question
or