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

Retrive specific child objects via OGL or use Fetch groups?

1 Answer 89 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.
G
Top achievements
Rank 1
G asked on 08 Nov 2009, 05:47 PM
Hi,

I'm new to OA so not sure of the best way to tackle the following simplified scenario.

I have a parent entity that contains several collections of differing child types.

I want to only populate the child types based on various criteria. For instance just get the children of a parent entity that are between a date range. 

I can't figure out how to do this in ogl. I can't see how the child is linked back to the parent, there isn't an id field present in the child entity.

I looked at fetch groups but we have a large amount of data and we know at runtime what subsets we need so thought it would be easier to query the related child entities and just bring into scope the data we require.

In straight SQL I would do this like:
 
select 
    ch.*  
from 
    child ch  
inner join 
    parent_child pc  
on  pc.child_id = ch.child_id  
inner join 
    parent p  
on  p.parent_id = pc.parent_id  
where 
    p.project_id = 20 


Thanks,

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 09 Nov 2009, 02:18 PM
Hi G,

You could use the existing object references. Most probably in your child object you have a reference to the parent. You can use it to navigate to the project id of the parent. In OQL, the query you provided, would look like this:
IQuery query = scope.GetOqlQuery("SELECT * FROM ChildExtent AS ch WHERE ch.Parent_child.Parent.Project_id == 20");

I hope that helps you.

Regards,
Damyan Bogoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
OQL (OQL specific questions)
Asked by
G
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or