ObjectScope Refresh

Thread is closed for posting
2 posts, 1 answers
  1. lkeel
    lkeel avatar
    115 posts
    Member since:
    Jul 2012

    Posted 16 Oct 2009 Link to this post

    I am new to OpenAccess, so please forgive me for this newbie question.

    I have some classes that map to data that is being manipulated by outside objects.  I know when these actions occur, so I know that my ORM data is out of sync.  I found the IObjectScope.Refresh method, but it is unclear to me what I am suppose to pass in.  It appears I should be passing in an instance of some object, but I am not sure what object that is.  So for example:

    I have an OpenAccess class that contains information from a view that joins several tables together.  There is another action that will remove a row and add a new row to this view at which time I need to refresh the collection of view data.

    Please help.
  2. Answer
    Semo avatar
    6 posts

    Posted 20 Oct 2009 Link to this post

    Hello lkeel,

    The method IObjectScope.Refresh( object persistentObject ) refreshes the state of an object getting the latest values for it from the database. You can use it to update an object which data in the database may have been changed by another process.
    As far as I understand you are having another process (or processes) that are changing regularly the data in your database. To get its current state you need to follow these steps:
    1. Start a new transaction with scope.Transaction.Begin(), so you get rid of the data that is stored in the cache;
    2. Execute a query to get the latest data from the database (the cache is already evicted).
    Keep in mind to call scope.Transaction.Commit() if you want to send to the database any modifications your application might have made or scope.Transaction.Rollback() otherwise.
    I hope that helps.

    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