Class CollectionTarget<TInput, TCollection>
A dataflow worker with one Input, that consumes incoming rows and adds them to
the Rows ICollection<T>, which by default is a List<T>.
Note: Use the factory methods in CollectionTargetFactory to create instances of this class.
Also note that the collection will use enough memory to hold all incoming rows.
Inheritance
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public class CollectionTarget<TInput, TCollection> : WorkerBase<CollectionTarget<TInput, TCollection>>, IDisposeOnFinished where TInput : class where TCollection : class, ICollection<TInput>
Type Parameters
| Name | Description |
|---|---|
| TInput | The type of each |
| TCollection | The type of the collection, e.g. List<T>. |
Properties
InitialCapacity
Gets or sets the initial capacity if the worker creates the collection.
Set to less than 1 to get the default (16 items).
Consider setting a large capacity, ideally the exact number of rows that will be received,
to minimize list allocations and copying. This does however increase up-front memory
utilization.
Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public int InitialCapacity { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
Input
Gets the input port for receiving rows from an upstream worker.
Declaration
public InputPort<TInput> Input { get; }
Property Value
| Type | Description |
|---|---|
| InputPort<TInput> |
Rows
Gets or sets the collection when the worker is not running. If null when the worker runs,
a List<T> will be created automatically, using InitialCapacity.
The populated collection is only available after the worker has completed successfully.
Note that the collection can optionally be set to null after the worker
has completed, to allow it to be garbage collected before the worker itself is garbage collected,
which can be useful in rare circumstances, e.g. with a large collection when the worker itself
is retained for an extended time.
Note: This property is thread-safe.
Declaration
public TCollection Rows { get; set; }
Property Value
| Type | Description |
|---|---|
| TCollection |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot get or set the value while the worker is running. |
Methods
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing. In this case, the base class base.RunAsync() must
be called for the worker to function correctly.
Typically, this worker is used without overriding this method.
Declaration
protected override async Task<OutcomeStatus> RunAsync()
Returns
| Type | Description |
|---|---|
| Task<OutcomeStatus> | A |