using System.Collections.Generic;
public int Id { get; set; }
public NodeType Type { get; set; }
public int ParentId { get; set; }
public string Comment { get; set; }
public string Title { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int? DatabaseId { get; set; }
public string Value { get; set; }
public bool? Enabled { get; set; }
public int? ValueTypeId { get; set; }
public class ServiceSettingsGroup
public int Id { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public string Comment { get; set; }
private static List<TreeNode> FillRecursive(List<ServiceSettingsGroup> flatObjects, int? parentId=null)
return flatObjects.Where(x => x.ParentId.Equals(parentId)).Select(item => new TreeNode
Children = FillRecursive(flatObjects, item.Id)
public static void Main()
var groupsList = new List<ServiceSettingsGroup>() {
Name = "Настройки каратнина транзакций",
Name = "Максимально допустимое запаздывание транзакции",
Name = "Максимально допустимое опережение транзакции",
Name = "Максимально допустимая сумма транзакции",
Name = "банковская карта «Мир»",
var tree = FillRecursive(groupsList, null);