Yo, DB folk

Post Reply
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

Anyone doinked around with SQL Server 2008's HierarchyID data type ... specifically for storing trees?
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
TheCatt
Site Admin
Posts: 58193
Joined: Thu May 20, 2004 11:15 pm
Location: Cary, NC

Post by TheCatt »

No, but I'm intrigued. What are you doing with it?
It's not me, it's someone else.
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

We've got an arbitrary hierarchical tree that's stored in a DB in the standard way -- every row has a column pointing to the ID of the parent row. SQL Server 2008 has this new-fangled HierarchyId data type that's not only supposed to glue the tree together, but provide other bits of useful tree functions (insert, delete, etc.). We're deciding whether to keep the old way or go the new way.
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
DoctorChaos
Posts: 1579
Joined: Fri Oct 08, 2004 7:58 pm

Post by DoctorChaos »

This might be me being cynical, but I would avoid their new fangled toys since it probably won't work the same in the next release. Sorry, feeling a little crusty.
Wadda mean? Other people can read this?!
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

Found a way to bullshit hierarchy IDs into playing nice with EF. If you store trees in a DB, this thing seems to be the way to go.
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
thibodeaux
Posts: 8121
Joined: Thu May 20, 2004 7:32 pm

Post by thibodeaux »

Interesting.
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

I spoke a bit too soon. I figured out a way to make EF take the data without problems. The operations are another story...

EF sees the corresponding C# type as untrusted & refuses to run any methods associated with it. It's not that hard to simulate that functionality yourself, though, if you really want to. If you search and return entire subtrees or need to fuck with your tree structurally, it's still the way to go.
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
Post Reply