Clearing fetch strategy?

5 posts, 0 answers
  1. Kendall Bennett
    Kendall Bennett avatar
    80 posts
    Member since:
    Feb 2010

    Posted 14 Jul 2011 Link to this post

    I am learning how to use the Fetch Strategies with OpenAccess, and the way it works is that I create the strategy I want and then assign it to the context. Then I make my queries and things will happen as expected.

    However what am I supposed to do the clear the fetch strategy when I am done with it, since we use the same context for the life of a single web request? I assume if I leave it attached, if another piece of code uses the same context to make a query, it will end up loading the data with the same fetch plan, which may or may not be what I want.

    I am thinking that I should probably just reset the fetch plan after call my query to get the objects I am looking for out of the database, by just assigning a null to the context.FetchStrategy field?
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 15 Jul 2011 Link to this post

    Hi Kendall Bennett,

    You can reset the strategy by assigning a new instance of the FetchStrategy class to the FetchStrategy property of the context instance:
    context.FetchStrategy = new FetchStrategy();

    Setting the property to null would not reset the fetch strategy but would keep the last one used.
    I hope that helps.

    Best wishes,
    Alexander
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. Kendall Bennett
    Kendall Bennett avatar
    80 posts
    Member since:
    Feb 2010

    Posted 16 Jul 2011 Link to this post

    Ok thanks. I would be a lot simpler API wise if there was a way to clear this than assigning a fresh instance (such as assigning a null to it), and it would be nice if this was better documented.
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 18 Jul 2011 Link to this post

    Hello Kendall Bennett,

    You are right, I added this to our TODO list. Thank you for bringing it to our attention.

    Best wishes,
    Alexander
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Kendall Bennett
    Kendall Bennett avatar
    80 posts
    Member since:
    Feb 2010

    Posted 18 Jul 2011 Link to this post

    By default when no fetch strategy is set to null, so it would be logical that setting it back to null would clear the fetch strategy?
Back to Top
DevCraft banner