Skip Navigation LinksHome / Community & Support / Code Library / Telerik OpenAccess ORM > General and Integration Projects > Implementing Context factory for Telerik OpenAccess ORM

Not answered Implementing Context factory for Telerik OpenAccess ORM

Feed from this thread
  • Posted on Aug 7, 2009 (permalink)

    Requirements

    RadControls version

    2009 Q2
    Telerik OpenAccess ORM version 2010.1.414.3
    .NET version

    3.5 SP1
    Visual Studio version

    2008
    programming language

    C#
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION

    This is an example of how  a so called 'context factory' is implemented. The .zip file contains 3 projects:

    1) Model (Data Model)
    2) Repository (BLL)
    3) Website (UI)

    It uses the Northwind database on a SQL2005 server.
    The basic idea is to have a few repositories for each 'set of entities'. So for example an 'OrderRepository' contains functionality to get 'Orders' from the database, but also the 'OrderDetails'.

    The only thing that is needed to get a repository together with an active scope (that is based per Http Session) is to call this:

    1 ArticleRepository repArticle = ContextFactory.Get<ArticleRepository>(Session.SessionID); 

    So then the ContextFactory is asking the RepositoryFactory to return a repository of the type 'ArticleRepository' using the 'active scope' for a particular session.


    UPDATE:The most recent version of this project can be found in the Software Development Kit, which you can download here. In case you have questions related to this project, please use the support ticketing system.

  • Gary avatar

    Posted on Aug 15, 2009 (permalink)

    Hi,

    I have implemented something like the repository factory on a per Http request basis.
    What is the advantage of having the repositories persist for a session?

    The example stores the dictionary as a static variable, why is it not stored as a session variable.
    Am I missing something simple here?

    Thanks
    Gary

  • Zoran Zoran admin's avatar

    Posted on Aug 20, 2009 (permalink)

    Hi Gary,

    The advantage of this approach is that every user that visits the web site gets to work with his/her own object scope, hence his/her own repository. The scope should not be shared by multiple users/sessions because it is not synchronized by itself. On the other hand, all object scope that will enter the dictionary(as in the implementation we discuss) will share the 2nd level cache. So from the perspective of using cached objects, the data access will still be optimized.

    Greetings,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  • CodeMonkey avatar

    Posted on Oct 31, 2009 (permalink)

    What about when the session finishes; how are the IObjectScopes removed from the ScopeFactory?

    [edit 1/11/09] In fact this design seems to be at odds to the best practices presented in http://www.telerik.com/support/kb/orm/general/best-practices-with-openaccess.aspx

  • Zoran Zoran admin's avatar

    Posted on Nov 2, 2009 (permalink)

    Hi CodeMonkey,

    Yes you are right, the scope should be disposed of when the Session ends as presented in the best practice KB article.

    Kind regards,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Damyan Bogoev Damyan Bogoev admin's avatar

    Posted on Jun 13, 2011 (permalink)


    The most recent version of this project can be found in the Software Development Kit, which you can download here. In case you have questions related to this project, please use the support ticketing system.

    All the best,
    Damyan Bogoev
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / Telerik OpenAccess ORM > General and Integration Projects > Implementing Context factory for Telerik OpenAccess ORM