Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Optimal way to retreive SQL data into Tree Structu

Author  Topic 

amrish_deep
Starting Member

1 Post

Posted - 2009-05-26 : 20:05:38
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??

Regards,
Amrish

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-27 : 02:26:47
It's hard to tell without seeing your table structure and without some sample data.
My best guess is that you will need to use the MSDATASHAPE provider.




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -