Hi,
I'm using a treeview to show a list of sections. I wrote some recursive functions to take care of this. However when I try to update my entities i get a whole lot of issues to overcome:
private void deleteSectionToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( tvSections.SelectedNode != null )
{
int SectionID = Convert.ToInt32( tvSections.SelectedNode.Tag );
ProjectSectionEntity section = GetEntityFromProject( SectionID );
if ( section != null )
{
if ( MessageBox.Show(
string.Format("This section has {0} childs, they will be moved to \"{1}\".", section.ProjectSectionChilds.Count, section.ProjectSection.Name),
"Delete?" , MessageBoxButtons.YesNo ) == DialogResult.Yes )
{
// add childs to the parent
section.ProjectSection.ProjectSectionChilds.AddRange( section.ProjectSectionChilds );
/////// REMOVE ///////////
// repopulate tree
PopulateSectionTree( );
}
}
}
}
After I have called the .Count function, the collection appears to be empty? Im trying to rearrange the child entities to the parent entity, but whatever I try I do not seem to get it to work as I can not use the AddRange function as the childs collection has been changed? I tried using the prefetch path before get all data before editing but again after calling .Count my collection is empty.
Anyone know how to solve this?