ObjectScope vs GetNewObjectScope

5 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 18 Jun 2010 Link to this post

    ...what's the difference between ObjectScope & GetNewObjectScope

    I've always used GetNewObjectScope but the telerik tv clips are all using ObjectScopeProvider1.ObjectScope()


  2. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 21 Jun 2010 Link to this post

    Hi Steve,

    As far as I remember... The GetNewObjectScope() gets you a new object scope from the Database instance associated (loaded and cached upon first call) with the ObjectScopeProvider.
    However, the ObjectScope property will give you the same instance of an already initialized object scope.

    Regards

    Henrik
  3. DevCraft banner
  4. Ady
    Admin
    Ady avatar
    588 posts

    Posted 23 Jun 2010 Link to this post

    Hello Steve

     As rightly pointed out by Henrik, 'ObjectScope()' always returns the same IObjectScope instance that is initialized the first time you invoke the method.
    'GetNewObjectScope()' , as the name suggests, returns a new instance of the scope always.

    Greetings,
    Ady
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 23 Jun 2010 Link to this post

    So I should ignore ObjectScope and use GetPerRequestObjectScope for a web project?
  6. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 23 Jun 2010 Link to this post

    Hi Steve,

    Yeah, that's right. The GetPerRequestObjectScope() does the housekeeping for you in respect to the best practices for web development.
    Basically, it stores the retrieved object scope, so that each time you call the method GetPerRequestObjectScope() during a single request, you'll get the same instance of the object scope.

    Regards

    Henrik
Back to Top
DevCraft banner