c# - Self-referencing table with parent-child relationship to represent file tree using LINQ -


I have a single database table representing the file tree structure.

  files - id (primary, primary key) - name - parent id (foreign key for files, id)   

How can I write a method Which ensures that the parents of all parents can not have the ID

UPDATE: I use SQL Server 2008 which supports the hierarchy ID, will it be helpful? (I'm not sure EF supports it)

You can probably add that value The "level" and then you need to make sure that a node does not have a parent, which has a level that has its equivalent or its equivalent when you add nodes, then you have a new node Node will set parent node to level + 1.

Cheers

Comments