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

OQL query help

1 Answer 78 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.
Jonathan
Top achievements
Rank 1
Jonathan asked on 24 Feb 2009, 10:37 AM
Hi, I am new to OQL and am having some problems with basic queries in the OQL browser. Perhaps you could help.

I have a Company table and Contact table with an intermediate table called CompanyContact which just holds the companyID and ContactID. Nothing out of the ordinary.

When I run the OQL

 

SELECT company.companyName, contact.lastName FROM CompanyExtent AS company,   
company.companyContact as contact where   
company.companyId="2763af0f-57ec-4f20-a913-b190fd94485e"  

all I get in the OQL results grid is a column labelled 'Content' with the company name list and no contact.lastName. If I run the generated SQL in SQLServer, I get what I would expect, ie the company name repeated with each contact's lastname.

  • Why does the OQL browser results grid display something different?

 

  • Why does the results grid display one column entitled 'Content' if I run the OQL
SELECT contact.firstName, contact.lastName FROM CompanyExtent AS company,   
company.companyContact as contact where   
company.companyId="2763af0f-57ec-4f20-a913-b190fd94485e"  

or is OQL just too different from TSQL?

Regards,
Jonathan





1 Answer, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 24 Feb 2009, 01:45 PM
Hi Jonathan Simmons,
Yes, it is different :)

Oql is object oriented, your query is still relational. You want to have a customer with a specific id that refers to a Contact.

You can just say select * from CompanyExtent as c where c.companyId == ... This will return real Company objects and you just navigate to the CompanyContact and you will have the contact in memory as well.

Sincerely yours,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
OQL (OQL specific questions)
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Share this question
or