Flattens a tree structure.
Syntax
public static DocumentList<TDocument> Flatten<TDocument>(this IEnumerable<TDocument> documents, string treePlaceholderKey, string childrenKey = "Children")
where TDocument : IDocument
This extension will either get all descendants of all documents from
a given metadata key (
Children
by default) or all
descendants from all metadata if a
null
key is specified. The
result also includes the initial documents in both cases.
The documents will be returned in no particular order and only distinct
documents will be returned (I.e., if a document exists as a
child of more than one parent, it will only appear once in the result set).
Type Parameters
Name |
Description |
TDocument |
|
Parameters
Name |
Type |
Description |
documents |
IEnumerable<TDocument> |
The documents to flatten. |
treePlaceholderKey |
string |
The metadata key that identifies placeholder documents (TreePlaceholder by default).
If null , tree placeholders will not be removed.
|
childrenKey |
string |
The metadata key that contains the children or null to flatten documents in all metadata keys. |
Return Value
Type |
Description |
DocumentList<TDocument> |
The flattened documents. |