New Posts New Posts RSS Feed: clearing deleted items from a collection of child objects
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

clearing deleted items from a collection of child objects

 Post Reply Post Reply
Author
dennism View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Mar-2008
Location: United States
Posts: 8
Post Options Post Options   Quote dennism Quote  Post ReplyReply Direct Link To This Post Topic: clearing deleted items from a collection of child objects
    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));

}

Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down