模型中是否有可能具有递归属性?目标是为每个操作动态构建一个字符串。这是我正在使用的:
public class Action
{
public int ActionId { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public string ActionName {
{
get
{
// example result: 1Ai or 2Bi
return ....
}
}
}
List<Action> aList = new List<Action>() {
new Action { ActionId = 1, Name = "Step 1" },
new Action { ActionId = 2, Name = "Step 2" },
new Action { ActionId = 3, ParentId = 1, Name = "A" },
new Action { ActionId = 4, ParentId = 1, Name = "B" },
new Action { ActionId = 5, ParentId = 2, Name = "A" },
new Action { ActionId = 6, ParentId = 2, Name = "B" },
new Action { ActionId = 5, ParentId = 3, Name = "i" },
new Action { ActionId = 6, ParentId = 6, Name = "i" }
}