Class Aggregation<TInput, TOutput>

Aggregates data by the given aggregation methods. The aggregate is a partial-blocking transformation - only the aggregation values are stored in separate memory objects. When all rows have been processed by the aggregation, the aggregated values are written into the output.

Inheritance
object
DataFlowTransformation<TInput, TOutput>
Aggregation<TInput, TOutput>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: ETLBox.DataFlow
Assembly: ETLBox.dll
Syntax
    public class Aggregation<TInput, TOutput> : DataFlowTransformation<TInput, TOutput>, ILoggableTask, IDataFlowLogging, IDataFlowTransformation<TInput, TOutput>, IDataFlowSource<TOutput>, IDataFlowSource, IDataFlowDestination<TInput>, IDataFlowDestination, IDataFlowComponent
Type Parameters
NameDescription
TInput

Type of ingoing data.

TOutput

Type of outgoing data.

Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

Constructors

Aggregation()

Declaration
    public Aggregation()
Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

Aggregation(Action<TInput, TOutput>, Func<TInput, object>, Action<object, TOutput>)

Declaration
    public Aggregation(Action<TInput, TOutput> aggregationAction, Func<TInput, object> groupingFunc, Action<object, TOutput> storeKeyAction)
Parameters
TypeNameDescription
System.Action<T1, T2><TInput, TOutput>aggregationAction

Sets the AggregationAction

System.Func<T, TResult><TInput, object>groupingFunc

Sets the GroupingFunc

System.Action<T1, T2><object, TOutput>storeKeyAction

Sets the StoreKeyAction

Aggregation(Action<TInput, TOutput>, Func<TInput, object>)

Declaration
    public Aggregation(Action<TInput, TOutput> aggregationAction, Func<TInput, object> groupingFunc)
Parameters
TypeNameDescription
System.Action<T1, T2><TInput, TOutput>aggregationAction

Sets the AggregationAction

System.Func<T, TResult><TInput, object>groupingFunc

Sets the GroupingFunc

Aggregation(Action<TInput, TOutput>)

Declaration
    public Aggregation(Action<TInput, TOutput> aggregationAction)
Parameters
TypeNameDescription
System.Action<T1, T2><TInput, TOutput>aggregationAction

Sets the AggregationAction

Properties

AggregateColumns

This list will be used to set the AggregationAction. This also works with ExpandoObjects.

Declaration
    public ICollection<AggregateColumn> AggregateColumns { get; set; }
Property Value
TypeDescription
System.Collections.Generic.ICollection<T><AggregateColumn>

AggregationAction

This action describes how the input data is aggregated. Not needed if you use the AggregateColumn in your object or pass a list to the AggregateColumns property.

Declaration
    public Action<TInput, TOutput> AggregationAction { get; set; }
Property Value
TypeDescription
System.Action<T1, T2><TInput, TOutput>

AggregationCondition

When the aggregation condition is set, the pre-defined aggregation methods are only executed if this condition evaluates to true. Only applicable if you set AggregateColumn attributes on your object or if you defined your columns via the
AggregateColumns property. This func will be invoked before every aggregation (e.g. every count is Count is set for a property, and contains the currently processed row along with the current property name and aggregation method.

Declaration
    public Func<TInput, AggregationMethodInfo, bool> AggregationCondition { get; set; }
Property Value
TypeDescription
System.Func<T1, T2, TResult><TInput, AggregationMethodInfo, bool>

GroupColumns

This list will be used to set the GroupingFunc and the StoreKeyAction. This also works with ExpandoObjects.

Declaration
    public ICollection<GroupColumn> GroupColumns { get; set; }
Property Value
TypeDescription
System.Collections.Generic.ICollection<T><GroupColumn>

GroupingFunc

This Func defines how the object for grouping data is retrieved. Not needed if you use the GroupColumn in your object or pass a list to the GroupColumns property.

Declaration
    public Func<TInput, object> GroupingFunc { get; set; }
Property Value
TypeDescription
System.Func<T, TResult><TInput, object>

SourceBlock

SourceBlock from the underlying TPL.Dataflow which is used as output buffer for the component.

Declaration
    public override ISourceBlock<TOutput> SourceBlock { get; }
Property Value
TypeDescription
ISourceBlock<><TOutput>
Overrides
ETLBox.DataFlow.DataFlowSource<TOutput>.SourceBlock

StoreKeyAction

This action defines how the grouping object is written back into the aggregated object. Not needed if you use the GroupColumn in your object or pass a list to the GroupColumns property.

Declaration
    public Action<object, TOutput> StoreKeyAction { get; set; }
Property Value
TypeDescription
System.Action<T1, T2><object, TOutput>

TargetBlock

TargetBlock from the underlying TPL.Dataflow which is used as input buffer for the component.

Declaration
    public override ITargetBlock<TInput> TargetBlock { get; }
Property Value
TypeDescription
ITargetBlock<><TInput>
Overrides
ETLBox.DataFlow.DataFlowTransformation<TInput, TOutput>.TargetBlock

TaskName

A name to identify the task or component. Every component or task comes with a default name that can be overwritten.

Declaration
    public override string TaskName { get; set; }
Property Value
TypeDescription
string
Overrides

Methods

CheckParameter()

Declaration
    protected override void CheckParameter()
Overrides
Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

CleanUpOnFaulted(Exception)

Declaration
    protected override void CleanUpOnFaulted(Exception e)
Parameters
TypeNameDescription
System.Exceptione
Overrides
Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

CleanUpOnSuccess()

Declaration
    protected override void CleanUpOnSuccess()
Overrides
Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

InitComponent()

Declaration
    protected override void InitComponent()
Overrides
Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

PrepareParameter()

Declaration
    protected override void PrepareParameter()
Overrides
Examples
public class MyDetailValue
{
    public int DetailValue { get; set; }
}
public class MyAggRow
{
    [AggregateColumn(nameof(MyDetailValue.DetailValue), AggregationMethod.Sum)]
    public int AggValue { get; set; }
}
var source = new DbSource<MyDetailValue>("DetailValues");
var agg = new Aggregation<MyDetailValue, MyAggRow>();
var dest = new MemoryDestination<MyAggRow>();
source.LinkTo<MyAggRow>(agg).LinkTo(dest);

Implements