nested classes in .NET generics

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

..net 3.5


i'm developing website where people can post comment on articles, and also
post comment on other comments.. nested

All comments belonging to an article has a link to the article, So no matter
what level in the tree the comment is, it always knows what article it is
created for....

In my webpage I want to use an ObjectDataSource which can get the collection
of comments and fill the datacontrol with it... Not sure how to pass a tree
of objects to a ObjectDataSource???

also I'm looking into how to design such nested class. Is it so that I just
create class and then add a field to that class which can hold the levels
underneath it, like this:

public class Comment {
private int _id;
private string _body;
private string _postedby;
private int _article;
private List<Comment> _replies

//I left out constructors etc from this example
}

any suggestions?
 
the ObjectDataSource only supports tabular data, not hierarchical data.
the XmlDataSource and the SiteMapDataSource are the only builtin one
that support hierarchical data like your threads. if these don't fit
your needs, you need to write your own datasource. there is a sample on
codeplex.

you class design look ok, but I'd add a back pointer (Parent) and maybe
siblings support.

-- bruce (sqlwork.com)
 
Back
Top