Print Page | Close Window

clearing deleted items from a collection of child objects

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=873
Printed Date: 05-May-2025 at 7:21pm


Topic: clearing deleted items from a collection of child objects
Posted By: dennism
Subject: clearing deleted items from a collection of child objects
Date Posted: 07-Jul-2008 at 9:41am

 
I have a grid of users on a winform and call a upate form to update the users and add/remove user roles. this is all derived form the ideablade role based tutorial.
 
I am having a problem with refreshing a grid detail view (dev express grid) after I delete one of the child detail items (user roles)
 
below is my form load and load user methods
 
I am using a span to get the userroles. before I added the span, the grid view of the parent user table was being refresh but not the related child user roles. after the span, new roles for the user that I add do show up but roles that I remove still are in the users object(user.user_roles).
 
When I return from the update form, I post a event back the grid window, and from that event I call load_users.
 
the debugger is clearly showing that deleted objects are not being cleared from the users object, even though they have been deleted from the sql server database.
 
What do I need to add to clear the deleted items?
 
private void UserBrowse_Load(object sender, EventArgs e)

{

//mPersMgr = PersistenceManager.DefaultManager;

mPersMgr = new PersistenceManager(CommonUser.CurrentUser.PersistenceManager);

InitializeBindingNavigator();

users.ApplySort(EntityPropertyDescriptors.User.UserName, ListSortDirection.Descending, true);

usersBS.DataSource = users;

userRolesXGBM.GridView = usersXGBM.AddRelationView("My User Roles", "MyUserRoles");

gridView1.LayoutChanged();

Load_Users();

}

void Load_Users()

{

mPersMgr.DefaultQueryStrategy = QueryStrategy.DataSourceOnly;

mLastQueryTs = DateTime.Now.AddMilliseconds(-mAsyncPeriod);

EntityQuery e = new EntityQuery(typeof(User));

e.AddSpan(EntityRelations.User_UserRole);

users.ReplaceRange(mPersMgr.GetEntities<User>(QueryStrategy.DataSourceOnly));

}




Replies:
Posted By: GregD
Date Posted: 07-Jul-2008 at 6:28pm
Dennism:
 
I'm not sure I have the whole picture yet, but why are you going back to the datasource to reload your user and user_role data when it's already in the cache?
 
Greg Dunn
IdeaBlade



Print Page | Close Window