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

Getting object scope of an object

2 Answers 53 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.
Assad
Top achievements
Rank 1
Assad asked on 12 Jan 2010, 05:06 PM
I have an object and I want to get the scope of that particular object. For e.g
For the class Customer, I get a particular customer c by using this.
Customer  c = BLL.MethodToGetCustomer(5); (creates the scope and returns a customer using that scope)

now I use this c all around the application. Is there any method or any way that I could call to retrieve the object scope of this particular object? Something like the following code
IObjectScope scope= GetObjectScope(c) (GetObjectScope is an imaginary method that retrieves the object scope).

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Pål
Top achievements
Rank 1
answered on 13 Jan 2010, 07:45 PM
            // Get ObjectScope for persistent object  
            IObjectScope objectScope = Database.GetContext(persistentObject) as IObjectScope; 

This should do the trick!

Pål
0
PetarP
Telerik team
answered on 15 Jan 2010, 09:53 AM
Hello Assad,

What Paul suggested should be perfectly sufficient to resolve your issue. Please also note that it is possible to edit the templates of Telerik OpenAccess ORM in order to add custom functionality to the generated classes. This would enable you to generate a custom method that can be called for each class instance. This method will perform the actions that Paul suggested and return an instance of IObjectScope. You can find additional information regarding the edit of the template files in this blog post.

Kind regards,
Petar
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.
Tags
General Discussions
Asked by
Assad
Top achievements
Rank 1
Answers by
Pål
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or