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));
}