internal int FillFromReader(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int startRecord, int maxRecords, DataColumn parentChapterColumn, object parentChapterValue)
{
int rowsAddedToDataSet = 0;
int schemaCount = 0;
do
{
AssertReaderHandleFieldCount(dataReader);
if (0 >= dataReader.FieldCount)
{
continue; // loop to next result
}
SchemaMapping mapping = FillMapping(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue);
schemaCount++; // don't increment if no SchemaTable ( a non-row returning result )
AssertSchemaMapping(mapping);
if (null == mapping)
{
continue; // loop to next result
}
if (null == mapping.DataValues)
{
continue; // loop to next result
}
if (null == mapping.DataTable)
{
continue; // loop to next result
}
mapping.DataTable.BeginLoadData();
try
{
// startRecord and maxRecords only apply to the first resultset
if ((1 == schemaCount) && ((0 < startRecord) || (0 < maxRecords)))
{
rowsAddedToDataSet = FillLoadDataRowChunk(mapping, startRecord, maxRecords);
}
else
{
int count = FillLoadDataRow(mapping);
if (1 == schemaCount)
{
// only return LoadDataRow count for first resultset
// not secondary or chaptered results
rowsAddedToDataSet = count;
}
}
}
finally
{
mapping.DataTable.EndLoadData();
}
if (null != datatable)
{
break; // do not read remaining results in single DataTable case
}
} while (FillNextResult(dataReader));
return rowsAddedToDataSet;
}