Deleting child objects from UI (search list result)

Deleting child objects from UI (search list result)

Old forum URL:

krasimir posted on Tuesday, November 16, 2010

I'm building a bug tracking system and I have the following hierarchy:


  - Project

     - Comment

     - Bug

        - Comment

When I bild the UI (most probably Silverlight and ASP.NET MVC and/or WebForms), I would like to provide the option for search and  display a list with all comments form all projects/bugs from all users. This is not a problem. The problem is what if I select one particullar comment and want to delete it?

What I understand from the book (2008 edition) is that the only way to delete a child object is to go to its parent object and delete it from the its collection, that holds the child object. But how will I know which is the parent of my selected child form the UI list, when even the static GetXXX() method of the child class should be internal and not public?

I wonder, wouldn't be easier to make the all the static ChildClass.GetXXX() methods public, so when I select the comment in my list in the UI, I will be able to get the Parent of the comment, and if the parent of the comment is also a child class (the second case in my first posting on this topic), then I will be able to get the Project object throught its static GetProject() method and then, finally to get the root User object. Once I know which is the right root object, I can delete the comment object without a problem.

However, this seems not so ellegant to me, I probably I miss something. Moreover, I'm sure there is a good reason for Rocky to made the GetXXX() methods internal and not public.

Please advise.

Copyright (c) Marimer LLC