Here is the code:
public IEnumerable<SomeItem> DescendantsAndSelf()
{
yield return this;
foreach (var item in Children.SelectMany(x => x.DescendantsAndSelf())
{
yield return item;
}
}
I got this code from here: https://stackoverflow.com/a/4814278/184773
This is a recursive linq query. i want to implement this but afraid it my bring my server down. Do you know if this performans multiple run trips to the server?