Is it possible to use FetchStrategy with Classic OpenAccess?

5 posts, 0 answers
  1. Peter
    Peter avatar
    23 posts
    Member since:
    Sep 2008

    Posted 17 Jan 2011 Link to this post

    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
  2. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 20 Jan 2011 Link to this post

    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.
  3. DevCraft banner
  4. Koen
    Koen avatar
    1 posts
    Member since:
    Sep 2010

    Posted 08 Feb 2011 Link to this post

    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
  5. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 11 Feb 2011 Link to this post

    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.
  6. Alexander
    Alexander avatar
    1 posts
    Member since:
    Mar 2011

    Posted 24 Nov 2011 Link to this post

    Good post, works perfectly :)
Back to Top
DevCraft banner