Class structure
public clas Item
{
public Item Parent { get; set; }
public string Code { get; set; }
}
example tree
AAA
- AAB
- BBB
CCC
- CCA
So i want to filter tree by CODE == BBB and result should be
AAA
- AAB
- BBB
but if i filter like this
IQueryable<Item> itemsQuery = GetQuery();
itemsQuery = itemsQuery.Where(x => x.Code == "BBB")
result does not contain parent nodes. So, how to include parent nodes, if their child nodes satisfy certain conditions?