Retrive specific child objects via OGL or use Fetch groups?

2 posts, 0 answers
  1. G
    G avatar
    14 posts
    Member since:
    May 2009

    Posted 08 Nov 2009 Link to this post

    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,
  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 09 Nov 2009 Link to this post

    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.
  3. DevCraft banner
Back to Top