Can someone describe the nested set model from a C#/LINQ perspective?
Posted
by Chad
on Stack Overflow
See other posts from Stack Overflow
or by Chad
Published on 2010-03-23T00:29:25Z
Indexed on
2010/03/23
0:31 UTC
Read the original article
Hit count: 423
I know the nested set model doesn't pertain to the C# language or LINQ directly... it's what I'm using to develop my web app.
For hierarchical data (categories with sub-categories in my case), I'm currently using something similar to the Adjacency List model. At the moment, I've only got 2 levels of categories, but I'd like to take it further and allow for n levels of categories using the nested set model.
I'm not quite clear on how to use it in a C# context. Here's the article I'm reading on the nested set model. Though this article cleared up my confusion some, I still have a big ?? in my head:
- Is inserting, updating or deleting categories tedious? It looks like the left and right numbers would require re-numbering... what would the LINQ queries look like for the following scenarios?
- Delete a child node (re-number all node's left/right values)
- Delete a parent node (what do you do with the orphans?)
- Move a child node to a different parent node (renumber again)
If my understanding is correct, at all times the child node's left/right values will always be between the parent node's left/right values, am I correct?
Seems easy enough, if only the categories were static... most likely I need to spend more time to get my head around the concept.
Any help is greatly appreciated!
© Stack Overflow or respective owner