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

OA needs to reload all items after commiting a single change

1 Answer 34 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.
Stefan Lorenz
Top achievements
Rank 1
Stefan Lorenz asked on 06 Jun 2010, 05:25 PM
Hi,

I've bound a RadGridView (Winforms) to a BindingList of Users (my persistent class) like so:

RadGridView.Datasource=new BindingList<Users>(from u in OSP.ObjectScope().Extent<User>() select u).ToList<User>());

After starting a transaction, changing a property of a single item and committing, objects are reloaded by OA one by one with separated Select commands once I scroll the gridview again. I don't understand why this is happening and how I can prevent this. I'd like the gridview to work with the initial loaded data or maybe just reload the changed item.

Thanks
Stefan

1 Answer, 1 is accepted

Sort by
0
Accepted
Damyan Bogoev
Telerik team
answered on 09 Jun 2010, 06:03 PM
Hi Stefan Lorenz,

You should use a new IObjectScope instance to retrieve the object which should be updated, update its fields and commit those changes:

using (IObjectScope scope = DbScopeProvider.GetNewObjectScope())
{
    scope.Transaction.Begin();
    User user = scope.Extent<User>().FirstOrDefault();
    //update the user instance
    scope.Transaction.Commit();                
}

If you use the IObjectScope from the data binding statement, the ITransaction.Begin() method will invalidate all the data the grid is bound to. And on ITransaction.Commit() all the data will be invalided and refreshed.
Hope that helps.

Regards,

Damyan Bogoev
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.
Tags
Getting Started
Asked by
Stefan Lorenz
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or