Hierarchial Table to Typed Dataset?

  • Thread starter Thread starter Richard Brown
  • Start date Start date
R

Richard Brown

Ok, I'm looking through the newsgroups and searching the web, but hopefully
someone can point me in the proper direction a little faster....

I have a single SQL table as follows:

Category
CategoryId uniqueidentifer not null
Name varchar(50) not null
ParentId uniqueidentifer null

This table is used to store a category/subcategory tree with an unlimited
number of sub-sub categories, etc.

So, can a typed data set be created that allows for the loading of the data
in a tree-node format?
For example, the top level has NULL in the ParentId field, sub nodes contain
their Parent Id, etc.

If it is possible, how? I was looking through the XML designer and thought
maybe a complex type nested onto itself? But Im not sure
 
Richard Brown said:
Ok, I'm looking through the newsgroups and searching the web, but hopefully
someone can point me in the proper direction a little faster....

I have a single SQL table as follows:

Category
CategoryId uniqueidentifer not null
Name varchar(50) not null
ParentId uniqueidentifer null

This table is used to store a category/subcategory tree with an unlimited
number of sub-sub categories, etc.

So, can a typed data set be created that allows for the loading of the data
in a tree-node format?
For example, the top level has NULL in the ParentId field, sub nodes contain
their Parent Id, etc.

If it is possible, how? I was looking through the XML designer and thought
maybe a complex type nested onto itself? But Im not sure

The typed dataset will also have the flat representation. If you define the
relationship, you can have helper methods to navigate from one row to its
parent row, or to an array of child rows. But the typed dataaset will not
have tree structure.

David
 
Richard,

You're going to have a hard time getting the strongly typed dataset to do
what you want here.

I'd suggest a business object approach instead - objects you can nest as
deeply as necessary. You could probably make datasets pretend to do what you
want, but I think you're head would explode before you got it fully
working, - and binding would be impossible. If you implement IList on your
business objects, you should be able to use the WIndows.Forms datagrid to
test your hierarchy.

Kathleen
 
Back
Top