Select SelectMany null,
b => b.Children
Children,
selector(node)
selector - - b => b.Children,
IEnumerable<Branch> anonymousMethod(Branch b)
{
return b.Children;
}
, , b.Children.SelectMany(...) null.SelectMany(...), , .
Children null?
, . , virtual:
public virtual ICollection<Branch> Children { get; set; }
EF Branch , proxy, , Branch, , . , b.Children , EF , . , , .
, Flatten, , (selector(node)), (SelectMany) Flatten ( Flatten(x, selector), ).
Flatten node (.Concat(new[] { node })), ( Flatten node, ).
node , Flatten
public static IEnumerable<T> Flatten<T>(this T node, Func<T,IEnumerable<T>> selector)
{
return new[] { node }
.Concat(selector(node).SelectMany(x => Flatten(x, selector)));
}
. LINQ . , CTE ( ). ...