Getting object scope of an object

Thread is closed for posting
3 posts, 1 answers
  1. Assad
    Assad avatar
    5 posts
    Member since:
    Mar 2009

    Posted 12 Jan 2010 Link to this post

    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).

  2. Answer
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 13 Jan 2010 Link to this post

                // Get ObjectScope for persistent object  
                IObjectScope objectScope = Database.GetContext(persistentObject) as IObjectScope; 

    This should do the trick!

  3. PetarP
    PetarP avatar
    754 posts

    Posted 15 Jan 2010 Link to this post

    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,
    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.
Back to Top