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

Is it possible to use FetchStrategy with Classic OpenAccess?

4 Answers 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter
Top achievements
Rank 1
Peter asked on 17 Jan 2011, 05:52 PM
Hi

We'd like to use the FetchStrategy class (ie the LoadWith methods) to control how OpenAccess retrieves object graphs - it's a closer fit to what we want to do than using FetchGroups and FetchPlans.  However, we're using OpenAccess ORM Classic, so we don't have an OpenAccessContext subclass on which to set the FetchStrategy.  Is there a way to use it with IObjectScope?

Thanks, Peter

4 Answers, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 20 Jan 2011, 06:31 PM
Hi Peter,

The FetchStartegy class was exclusively introduced for the OpenAccessContext and the new domain model approach. You cannot use it with an IObjectScope. However, you should be able to achieve the same things with the FetchPlans and FetchGroups. Can you tell us a FetchStrategy scenario which you would like to accomplish so that we can assist you in providing an equivalent for the FetchPlans? Are there any other considerations which prevent you from using the FetchPlans for the IObjectScope? We would be glad to have your feedback.

Do not hesitate to contact us to further discuss the issue.

Kind regards,
Petko_I
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Koen
Top achievements
Rank 1
answered on 08 Feb 2011, 02:14 PM
Hi,

I have a similar problem. I'm trying to use the OpenAccessDataSource with a domain model. While this works, it uses lazy loading which is too slow for me (even using serverside paging with a page size of 20). To improve performance I tried subscribing to the OpenAccessDataSource.ContextCreated event to set the FetchStrategy, but the IObjectScope used in that event only supports FetchPlan.

As I've generated the model using the domain model approach, there is no way to edit Fetch plans using the menu's in Visual studio (even not when switching back to 'old menu entries').

I like the LoadWith API much better, how would one be able to use that with the OpenAccessDataSource? I'd rather not have half the code use FetchStrategy (code that doesn't use the DataSourceControl) and the other half FetchPlan.

Thanks, Koen
0
Petko_I
Telerik team
answered on 11 Feb 2011, 08:40 PM
Hello Peter,

Unfortunately, the new fetch optimization API (LoadWith) cannot be used directly with the OpenAccessDataSource. However, as you have correctly observed on the creation of the context for the OpenAccessDataSource you can assign an IObjectScope instance to the Context property of the OpenAccessDataSourceContextCreatingEventArgs. What you can actually do is initialize a new domain context, specify a FetchStrategy for it and then set the internal IObjectScope of the domain context for the OpenAccessDataSource. To get the internal scope you will need to expose it through a partial class definition of the domain context so that the automatic code generation does not override your changes:
public partial class NorthwindEntityDiagrams : OpenAccessContext
{
    public IObjectScope GetInternalScope()
    {
        return this.GetScope();
    }
}
We hope the provided information was helpful. Do not hesitate to contact us, should you face further difficulties.

Greetings,
Petko_I
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Alexander
Top achievements
Rank 1
answered on 24 Nov 2011, 05:53 PM
Good post, works perfectly :)
Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Koen
Top achievements
Rank 1
Alexander
Top achievements
Rank 1
Share this question
or