In-Memory data
The MemorySource and MemoryDestination allows you to read or write data from/into an IEnumerable - so any list or collection of the .NET ecosystem can be used as source or destination for an ETLBox data flow. The Memory connectors are available in the ETLBox core package.
The MemorySource
and MemoryDestination
are part of the ETLBox core package - you don’t need to reference any additional package to use these connectors.
If you want to start with example code right away, you will find it in the recipes section for the MemorySource and MemoryDestination. Both components are also used frequently in other examples.
MemorySource
A Memory source is a simple source component that accepts a .NET list, collection or simple enumerable. Use this component within your data flow if you already have a collection containing your data available in memory. When you execute the flow, the memory destination will iterate through the list and asynchronously post record by record into the flow.
Example
Here is an example code that uses your own list object to assign source data to the memory source.
The Data
property of the MemorySource will accept any IEnumerable<T>
.
Using the internal list
By default, the Data
property is always initialized with an empty ListData
has some limitations regarding records, you can use the property Data
DataAsList. This will try to cast the current list stored in
Datainto an
IList
Using dynamic object
The default implementation of the MemorySource works internally with an ExpandoObject.
Using arrays
You can also use the MemorySource with arrays.
MemoryDestination
A memory destination stores the incoming data within a List. You can access the received data within the Data
property. Data should be read from this collection when all data has arrived at the destination. If you want to access the data asynchronously while the list is still receiving data from the flow, consider using the ConcurrentMemoryDestination
. As the Data
property will internally use an List<T>
, accessing data in this list while your data flow is still running is not thread safe. See below the details for the ConcurrentMemoryDestination.
Example
Using dynamic objects
The default implementation of MemoryDestination
will use internal the ExpandoObject
Using arrays
You can use the MemoryDestination also with arrays.
Concurrent memory destination
The ConcurrentMemoryDestination
is almost the same as the MemoryDestination
, but instead of a ICollection<T>
for incoming data it uses a BlockingCollection<T>
to store incoming data.