OA needs to reload all items after commiting a single change

2 posts, 1 answers
  1. Stefan Lorenz
    Stefan Lorenz avatar
    13 posts
    Member since:
    May 2010

    Posted 06 Jun 2010 Link to this post

    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
  2. Answer
    Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 09 Jun 2010 Link to this post

    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.
  3. DevCraft banner
Back to Top