Select from List<TreeNode> only treenodes with certain categories.

Targutai Yesugei asked on December 15, 2017 16:03

Hello. I have List of treenodes, so i want to extract only treenodes with categories from another list i acquired by executing CategoryInfoProvider.GetCategories($"CategoryParentID = '{categoryParentID}'", orderBy);

How can i do this? I tried to use something like treeNodes.Where(x=>x.Categories.CodeNames.Intersect(requiredCategoryList)

But the problem is that treeNode.Categories.CodeNames isn't a List<string>.

Thanks in advance.

Recent Answers


Peter Mogilnitski answered on December 18, 2017 20:50 (last edited on December 18, 2017 20:52)

Try this:

// categoryParentID is defined above
var catByParent = CategoryInfoProvider.GetCategories().WhereEquals("CategoryParentID", categoryParentID).Columns("CategoryID");
var documentCategories = DocumentCategoryInfoProvider.GetDocumentCategories().WhereIn("CategoryID", catByParent).Column("DocumentID");
var docs = DocumentHelper.GetDocuments().WhereIn("DocumentID", documentCategories);
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.