public class MyRow
{
public int Id { get ; set ; }
public string Value { get ; set ; }
}
var source = new MemorySource < MyRow >();
for ( int i = 0 ; i < 10 ; i ++)
source . DataAsList . Add ( new MyRow () { Id = i , Value = "Test" + i });
int batchNumber = 1 ;
var dataByBatchNumber = new Dictionary < int , List < MyRow >>();
var batchDest = new CustomBatchDestination < MyRow >( 100 ,
( batch , pg ) => {
dataByBatchNumber . Add ( batchNumber , batch . ToList ());
batchNumber ++;
});
batchDest . BatchSize = 3 ;
source . LinkTo ( batchDest );
Network . Execute ( source );
foreach ( var row in dataByBatchNumber )
Console . WriteLine ( "Batchnumber:" + row . Key + " has " + row . Value . Count + " records." );
/* Output
Batchnumber:1 has 3 records.
Batchnumber:2 has 3 records.
Batchnumber:3 has 3 records.
Batchnumber:4 has 1 records.
*/