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

Clearing fetch strategy?

4 Answers 62 Views
Development (API, general 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.
Kendall Bennett
Top achievements
Rank 2
Kendall Bennett asked on 15 Jul 2011, 02:52 AM
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?

4 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 15 Jul 2011, 01:13 PM
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!

0
Kendall Bennett
Top achievements
Rank 2
answered on 16 Jul 2011, 08:22 PM
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.
0
Alexander
Telerik team
answered on 18 Jul 2011, 04:14 PM
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!

0
Kendall Bennett
Top achievements
Rank 2
answered on 18 Jul 2011, 04:18 PM
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?
Tags
Development (API, general questions)
Asked by
Kendall Bennett
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Kendall Bennett
Top achievements
Rank 2
Share this question
or