David Glover
asked on
How can this FindAll query be reworked to return the combined list of qualifying objects?
In this simple example below I have some nested lists and I want the root to be able to return a list of the grandchildren that match a predicate.
Thank you,
Class cFruits
Property Fruits as List(Of cFruit)
Function VegetarianRecipes() As List(Of cRecipe)
'The following line is wrong as it returns the cFruits that have a vegetarian Recipe and not the Recipes themselves.
'How do I rework the linq to return the cRecipe as one list even though they are sourced from seperate lists?
Return Fruits.FindAll(Function(f) f.Recipes.FindAll(Function(x) x.Vegetarian = True).Count > 0)
End Function
End Class
Class cFruit
Property Recipes as List(Of cRecipe)
End Class
Class cRecipe
Property Vegetarian As Boolean
End Class
How can the Return line in the Function VegetarianRecipes be modified to return a list of the grandchildren of type cRecipe that are vegetarian.Thank you,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.