0
模型中可能有遞歸屬性嗎?目標是爲每個動作動態構建一個字符串。這是我的工作:模型中的遞歸屬性
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" }
}