public class DB
{
public string Code { get; set; }
public string Name { get; set; }
public string Id { get; set; }
public string ParentId { get; set; }
}
DB dbA = new DB();
dbA.Id = 0;
db.ParentId = null;
DB dbB = new DB();
dbB.Id = 1;
dbB.ParentId = 0;
DB dbC = new DB();
dbC.Id = 2;
dbC.ParentId = 0;
DB dbD = new DB();
dbD.Id = 3;
dbD.ParentId = 2;
dbA (id=0)
|---dbB (id=1)
|---dbC (id=2)
|---dbD (id=3)