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

ObjectScope Refresh

1 Answer 69 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
lkeel
Top achievements
Rank 1
lkeel asked on 16 Oct 2009, 07:29 PM
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.
Lee

1 Answer, 1 is accepted

Sort by
0
Accepted
Semo
Telerik team
answered on 20 Oct 2009, 07:45 AM
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.

Regards,
Semo
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
Development (API, general questions)
Asked by
lkeel
Top achievements
Rank 1
Answers by
Semo
Telerik team
Share this question
or