Optimal way to retreive SQL data into Tree Structure

May 26 2009 3:27 PM
1. I have the following table structure
    a. Shape
    b. Shape Attributes
Shape Table contains an Shape's ID & Name
Shape Attribute contains shape details and every individual Shape entry can have multiple Shape Attributes (1:N)
2. In C#, I need to retrieve the Shape details using a stored procedure/query into a Shape Class.
3. One shape object is created for every individual row in the Shape Table
4. The Shape Attributes needs to go into a Key/Value pair inside the Shape Class

The Question is
---------------
What is the best optimal way to retrieve all the Shapes and the corresponding Attribute data and store it in an Object Array?

I thought of first retrieving the Shape List from the Shape Table and then loop through the shapes and for each shape, query the database again to get the

list of attributes.

The downside in this method is
1. For n shapes, n additional database access is needed for the attributes.

Is there any other optimal way to achieve this??