Fetch Plan for 1 to Many

Thread is closed for posting
5 posts, 1 answers
  1. John
    John avatar
    5 posts
    Member since:
    Sep 2012

    Posted 23 Jun 2010 Link to this post

    Hi Telerik,

    I have been able to use fetch plans to successfully retrieve referenced objects in a single query where there is a 1 to 1 relationship - for example if I query OrderDetail I can retrieve the referenced Order in a single query.

    I however want to be able to get an Order object and have the OrderDetail objects for that order pre-loaded in a single query.

    I have tried the following but I still seem to get 2 queries - the first for retrieving the order then another for retrieving the details.

            [Telerik.OpenAccess.FetchField("Order Details Fetch Group")]
            private IList<OrderDetail> orderDetails = new List<OrderDetail>();  // inverse OrderDetail.order

    Is it possible to use Fetch Plans to preload the "many" part of a 1 - Many relationship?

    Thanks
    John
  2. Answer
    Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 24 Jun 2010 Link to this post

    Hi John,
    It is possible to join the collection into the first query. To do so you have to set ParallelFetch = true on your query definition:

    OQL:
    IQuery query = scope.GetOQL(...);
    query.ParallelFetch = true;
    query.Execute(..)

    Linq:

    var result = from x in scope.Extent<Person>().ParallelFetch(true) where ...

    All the best,
    Jan Blessenohl
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. John
    John avatar
    5 posts
    Member since:
    Sep 2012

    Posted 24 Jun 2010 Link to this post

    Works a treat. Thanks.
  4. John
    John avatar
    5 posts
    Member since:
    Sep 2012

    Posted 24 Jun 2010 Link to this post

    Hi Jan,

    Can I suggest you add some information about ParallelFetch() to your documentation pages on Fetch Plans.

    Thanks
    John
  5. Pencho
    Admin
    Pencho avatar
    22 posts

    Posted 25 Jun 2010 Link to this post

    Hi John,

    Thanks a lot for your suggestion. We will revisit (update) the part of our documentation regarding the FetchPlans feature for our next release and we will include information about ParallelFetch. Meanwhile if you have any suggestions about how to improve our documentation, or if you note any missing content, do not hesitate to share with us - we will be very grateful.

    Best wishes,
    Pencho
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top