从C#中的嵌套无限foreach循环中获取结果

时间:2018-08-28 10:24:09

标签: c# loops nested-loops

{
"_id" : "5b851399aae4c61f808510ff",
"Brand" : 5,
"IsPublished" : false,
"RowItems" : [ 
    {
        "RowType" : 2,
        "Text" : "Parent Filter",
        "GroupId" : "49ba6faa-3bf3-48ab-a711-81a13aa82ee9",
        "LevelIndex" : 1,
        "ItemIndex" : 0,
        "RowItems" : [ 
            {
                "RowType" : 3,
                "Text" : "Audi UK marketing",
                "TagId" : "5762a477f5f79234582e5d94",
                "GroupId" : "617f08d8-721c-436e-96f7-fc0bb9006993",
                "LevelIndex" : 2,
                "ItemIndex" : 0,
                "RowItems" : []
            }, 
            {
                "RowType" : 3,
                "Text" : "Marketing",
                "TagId" : "577d2cdb2638c30cc82043a7",
                "GroupId" : "a7320624-17c8-407e-8728-8fbc4aec00f7",
                "LevelIndex" : 2,
                "ItemIndex" : 1,
                "RowItems" : []
            }, 
            {
                "RowType" : 3,
                "Text" : "Genuine parts",
                "TagId" : "5762a47ef5f79234582e5e05",
                "GroupId" : "6efaaaf1-4771-4152-be02-449730ce9943",
                "LevelIndex" : 2,
                "ItemIndex" : 2,
                "RowItems" : [ 
                    {
                        "RowType" : 2,
                        "Text" : "Genuine Parts Child",
                        "GroupId" : "0e1d215d-5140-43a9-8bf3-361bcc3e94b8",
                        "LevelIndex" : 3,
                        "ItemIndex" : 0,
                        "RowItems" : [ 
                            {
                                "RowType" : 3,
                                "Text" : "Claim compiling",
                                "TagId" : "5762a47cf5f79234582e5de1",
                                "GroupId" : "dfe8049a-2837-4d43-a4c9-58017dfab84d",
                                "LevelIndex" : 4,
                                "ItemIndex" : 0,
                                "RowItems" : []
                            }, 
                            {
                                "RowType" : 3,
                                "Text" : "Composite",
                                "TagId" : "5762a47cf5f79234582e5de5",
                                "GroupId" : "ef954354-1c9c-4c6a-ac09-ab7429e9a6eb",
                                "LevelIndex" : 4,
                                "ItemIndex" : 1,
                                "RowItems" : []
                            }
                        ]
                    }
                ]
            }
        ]
    }
],
"CreatedDate" : ISODate("2018-08-28T03:49:21.000Z"),
"CreatedBy" : "AM002PS",
"UpdatedDate" : ISODate("2018-08-28T09:20:17.957Z"),
"UpdatedBy" : "AM002PS"

}

在此嵌套RowItems。如果我传递了任何TagId,并且如果存在标签ID,则应该将RowItems作为结果。我想通过Linq实现这一目标。我需要某种通用方法来获取行项。 这里RowItems是嵌套的。如果我传递了任何TagId,并且如果存在标签ID,则应该将RowItems作为结果。我想通过Linq实现这一目标。我需要某种通用方法来获取行项

0 个答案:

没有答案