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

ObjectScope vs GetNewObjectScope

4 Answers 100 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 18 Jun 2010, 06:14 PM
...what's the difference between ObjectScope & GetNewObjectScope

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


4 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 21 Jun 2010, 10:10 AM
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
0
Ady
Telerik team
answered on 23 Jun 2010, 01:35 PM
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
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 23 Jun 2010, 01:36 PM
So I should ignore ObjectScope and use GetPerRequestObjectScope for a web project?
0
IT-Als
Top achievements
Rank 1
answered on 23 Jun 2010, 01:56 PM
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
Tags
Getting Started
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
IT-Als
Top achievements
Rank 1
Ady
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or