let me introduce a general approach that can be also adopted to more case specific details.
Assumptons:
- DataTable with 8 Rows
- Segmentsize: 3
Following Building Blocks are used
Calculation of the numbers of segments:
with the Ceiling method the fractions are uprounded to the next Integer
with the Skip() and Take() Method the Rows for a segment can be retrieved.
the different segments are bult by following
and do fetch the different segment rows by:
dtData.AsEnumerable.Skip(segment*SegmentSize).Take(SegmentSize).toList
does mean:
- Segment0: dtData.AsEnumerable.Skip(0*3).Take(3).toList - Row:0,1,2
- Segment1: dtData.AsEnumerable.Skip(1*3).Take(3).toList - Row:3,4,5
- Segment2: dtData.AsEnumerable.Skip(2*3).Take(3).toList - Row:6,7
Detecting if a segment is incomplete or not the modulo function helps
Giving an impression on the processing result, refer to logs below:
Find starter Help here:
ForEach_Segment_RowSets.xaml (11.5 KB)