Tree Structure in CSLA

Tree Structure in CSLA

Old forum URL: forums.lhotka.net/forums/t/183.aspx


PitDog posted on Tuesday, May 23, 2006

Hello all,

Perhaps this is not the right place to post something like this however I have been reading this for months and decided to ask.

I faced with an problem at work where I need to model a simple tree structure from a database. For instance.

ID   PARENT_ID   NAME

1      NULL             Manager

2      1                     Employee

3      2                     Intern

4       NULL            President

5       4                     Gov

6        5                     Mayor

I am just looking at some general advise as to how one may model this. I would like to have the whole object graph created by the Root objects. Meaning if I go after a Parent I should get the entire object graph.

Any insight would be great. I will keep searching in the mean time.

 

PitDog

RockfordLhotka replied on Wednesday, May 24, 2006

Your object model should reflect your business (user's) use cases, not the data structure.

Is there really a case where the user needs to retrieve all the data in these objects all at once for the purpose of editing? Typically that's not a valid user scenario.

Instead, determine the user scenarios (use cases) that need to be implemented and design objects to match those scenarios. I discuss this in Chapter 6.

PitDog replied on Wednesday, May 24, 2006

Hey Rocky,

Thanks for the reply! One particular use case that I am speaking of is how the menu should work.

Imagine that I have a site selling cars. I want to create a menu that will allow for the user to navigate the cars that my site sells. Granted these are going to be read only objects I will still need to get a object graph with the data needed to build a menu below.

Ford

   -Vans

      -Van 1

      -Van 2

   -Cars

   -suv

VW

   -Cars

  - Vans

   -Suv

 

PitDog

 

P.S. I am very excited about the 2.0 version. I have used your 1.5 framework for 4 projects and it has proven well!!

skagen00 replied on Wednesday, May 24, 2006

I replaced NameValueListBase with a similar structure that contains list of nodes (not just name & value) that each node can contain links to other nodes in the list. After implementing IHierarchicalDataSource, I can bind my list to a DropDownList (with the text member being "Extended Display" to either do "-Cars" "--Honda" or "Vehicles/Cars/Honda" "Vehicle/Cars" or a TreeView control (because of IHierarchicalDataSource).

 

vbexpert replied on Wednesday, May 24, 2006

skagen00:

I replaced NameValueListBase with a similar structure that contains list of nodes (not just name & value) that each node can contain links to other nodes in the list. After implementing IHierarchicalDataSource, I can bind my list to a DropDownList (with the text member being "Extended Display" to either do "-Cars" "--Honda" or "Vehicles/Cars/Honda" "Vehicle/Cars" or a TreeView control (because of IHierarchicalDataSource).

Do you mind posting some code here? Thanks

CaymanIslandsCarpediem replied on Wednesday, May 24, 2006

There was actually a question much like this discussed on the old forum just prior to the move to this new one.  Here it is:

http://groups.msn.com/CSLANET/general.msnw?action=get_message&mview=0&ID_Message=26774&LastModified=4675571662244908534

Copyright (c) Marimer LLC