Usage
-
GroupByMany(DocumentConfig key, IEnumerable<IModule> modules)
Partitions the result of the specified modules into groups with matching keys based on the key delegate. The input documents to GroupBy are used as the initial input documents to the specified modules.
key
A delegate that returns the group keys.
modules
Modules to execute on the input documents prior to grouping.
-
GroupByMany(DocumentConfig key, params IModule[] modules)
Partitions the result of the specified modules into groups with matching keys based on the key delegate. The input documents to GroupBy are used as the initial input documents to the specified modules.
key
A delegate that returns the group keys.
modules
Modules to execute on the input documents prior to grouping.
-
GroupByMany(string keyMetadataKey, IEnumerable<IModule> modules)
Partitions the result of the specified modules into groups with matching keys based on the value at the specified metadata key. If a document to group does not contain the specified metadata key, it is not included in any output groups. The input documents to GroupBy are used as the initial input documents to the specified modules.
keyMetadataKey
The key metadata key.
modules
Modules to execute on the input documents prior to grouping.
-
GroupByMany(string keyMetadataKey, params IModule[] modules)
Partitions the result of the specified modules into groups with matching keys based on the value at the specified metadata key. If a document to group does not contain the specified metadata key, it is not included in any output groups. The input documents to GroupBy are used as the initial input documents to the specified modules.
keyMetadataKey
The key metadata key.
modules
Modules to execute on the input documents prior to grouping.
Fluent Methods
Chain these methods together after the constructor to modify behavior.
-
Where(DocumentConfig predicate)
Limits the documents to be grouped to those that satisfy the supplied predicate.
predicate
A delegate that should return a
bool
.
-
WithComparer(IEqualityComparer<Object> comparer)
Specifies an equality comparer to use for the grouping.
comparer
The equality comparer to use.
-
WithComparer<TValue>(IEqualityComparer<TValue> comparer)
Specifies a typed equality comparer to use for the grouping. A conversion to the comparer type will be attempted for all metadata values. If the conversion fails, the value will not be considered equal. Note that this will also have the effect of treating different convertible types as being of the same type. For example, if you have two group keys, 1 and "1" (in that order), and use a string-based comparison, you will only end up with a single group for those documents with a group key of 1 (since the
int
key came first).comparer
The typed equality comparer to use.
-
WithEmptyOutputIfNoGroups(bool emptyOutput = true)
Specifies that no documents should be output if there are no groups. This is in contrast to the default behavior of outputting the unmodified input documents if no groups were found.
emptyOutput
true
to not output documents when no groups are found.
Output Metadata
The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.
-
Keys.GroupDocuments
:IEnumerable<IDocument>
Contains all the documents for the current group.
-
Keys.GroupKey
:System.Object
The key for the current group.