private bool FillNextResult(DataReaderContainer dataReader) { bool result = true; if (_hasFillErrorHandler) { try { // only try-catch if a FillErrorEventHandler is registered so that // in the default case we get the full callstack from users result = dataReader.NextResult(); } catch (Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionForCapture(e); OnFillErrorHandler(e, null, null); } } else { result = dataReader.NextResult(); } return(result); }
private int FillLoadDataRow(SchemaMapping mapping) { int num = 0; DataReaderContainer dataReader = mapping.DataReader; if (!this._hasFillErrorHandler) { while (dataReader.Read()) { mapping.LoadDataRow(); num++; } return(num); } while (dataReader.Read()) { try { mapping.LoadDataRowWithClear(); num++; continue; } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionForCapture(exception); this.OnFillErrorHandler(exception, mapping.DataTable, mapping.DataValues); continue; } } return(num); }
private int FillLoadDataRow(SchemaMapping mapping) { int rowsAddedToDataSet = 0; DataReaderContainer dataReader = mapping.DataReader; if (_hasFillErrorHandler) { while (dataReader.Read()) { // read remaining rows of first and subsequent resultsets try { // only try-catch if a FillErrorEventHandler is registered so that // in the default case we get the full callstack from users mapping.LoadDataRowWithClear(); rowsAddedToDataSet++; } catch (Exception e) when(ADP.IsCatchableExceptionType(e)) { ADP.TraceExceptionForCapture(e); OnFillErrorHandler(e, mapping.DataTable, mapping.DataValues); } } } else { while (dataReader.Read()) { // read remaining rows of first and subsequent resultset mapping.LoadDataRow(); rowsAddedToDataSet++; } } return(rowsAddedToDataSet); }
internal object FillSchemaFromReader(DataSet dataset, DataTable datatable, SchemaType schemaType, string srcTable, IDataReader dataReader) { DataTable[] dataTables = null; int schemaCount = 0; do { DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes); AssertReaderHandleFieldCount(readerHandler); if (0 >= readerHandler.FieldCount) { continue; } string tmp = null; if (null != dataset) { tmp = DataAdapter.GetSourceTableName(srcTable, schemaCount); schemaCount++; // don't increment if no SchemaTable ( a non-row returning result ) } SchemaMapping mapping = new SchemaMapping(this, dataset, datatable, readerHandler, true, schemaType, tmp, false, null, null); if (null != datatable) { // do not read remaining results in single DataTable case return(mapping.DataTable); } else if (null != mapping.DataTable) { if (null == dataTables) { dataTables = new DataTable[1] { mapping.DataTable }; } else { dataTables = DataAdapter.AddDataTableToArray(dataTables, mapping.DataTable); } } } while (dataReader.NextResult()); // FillSchema does not capture errors for FillError event object value = dataTables; if ((null == value) && (null == datatable)) { value = Array.Empty <DataTable>(); } return(value); // null if datatable had no results }
private int FillLoadDataRowChunk(SchemaMapping mapping, int startRecord, int maxRecords) { DataReaderContainer dataReader = mapping.DataReader; while (0 < startRecord) { if (!dataReader.Read()) { // there are no more rows on first resultset return(0); } --startRecord; } int rowsAddedToDataSet = 0; if (0 < maxRecords) { while ((rowsAddedToDataSet < maxRecords) && dataReader.Read()) { if (_hasFillErrorHandler) { try { mapping.LoadDataRowWithClear(); rowsAddedToDataSet++; } catch (Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionForCapture(e); OnFillErrorHandler(e, mapping.DataTable, mapping.DataValues); } } else { mapping.LoadDataRow(); rowsAddedToDataSet++; } } // skip remaining rows of the first resultset } else { rowsAddedToDataSet = FillLoadDataRow(mapping); } return(rowsAddedToDataSet); }
private int FillLoadDataRowChunk(SchemaMapping mapping, int startRecord, int maxRecords) { DataReaderContainer dataReader = mapping.DataReader; while (0 < startRecord) { if (!dataReader.Read()) { return(0); } startRecord--; } int num = 0; if (0 >= maxRecords) { return(this.FillLoadDataRow(mapping)); } while ((num < maxRecords) && dataReader.Read()) { if (this._hasFillErrorHandler) { try { mapping.LoadDataRowWithClear(); num++; } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionForCapture(exception); this.OnFillErrorHandler(exception, mapping.DataTable, mapping.DataValues); } } else { mapping.LoadDataRow(); num++; } } return(num); }
internal object FillSchemaFromReader(DataSet dataset, DataTable datatable, SchemaType schemaType, string srcTable, IDataReader dataReader) { DataTable[] tables = null; int index = 0; do { DataReaderContainer container = DataReaderContainer.Create(dataReader, this.ReturnProviderSpecificTypes); if (0 < container.FieldCount) { string sourceTableName = null; if (dataset != null) { sourceTableName = GetSourceTableName(srcTable, index); index++; } SchemaMapping mapping = new SchemaMapping(this, dataset, datatable, container, true, schemaType, sourceTableName, false, null, null); if (datatable != null) { return(mapping.DataTable); } if (mapping.DataTable != null) { if (tables == null) { tables = new DataTable[] { mapping.DataTable }; } else { tables = AddDataTableToArray(tables, mapping.DataTable); } } } }while (dataReader.NextResult()); object obj2 = tables; if ((obj2 == null) && (datatable == null)) { obj2 = new DataTable[0]; } return(obj2); }
protected virtual int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords) { int num; IntPtr ptr; Bid.ScopeEnter(out ptr, "<comm.DataAdapter.Fill|API> %d#, dataSet, srcTable, dataReader, startRecord, maxRecords\n", this.ObjectID); try { if (dataSet == null) { throw ADP.FillRequires("dataSet"); } if (ADP.IsEmpty(srcTable)) { throw ADP.FillRequiresSourceTableName("srcTable"); } if (dataReader == null) { throw ADP.FillRequires("dataReader"); } if (startRecord < 0) { throw ADP.InvalidStartRecord("startRecord", startRecord); } if (maxRecords < 0) { throw ADP.InvalidMaxRecords("maxRecords", maxRecords); } if (dataReader.IsClosed) { return(0); } DataReaderContainer container = DataReaderContainer.Create(dataReader, this.ReturnProviderSpecificTypes); num = this.FillFromReader(dataSet, null, srcTable, container, startRecord, maxRecords, null, null); } finally { Bid.ScopeLeave(ref ptr); } return(num); }
protected virtual int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords) { long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DataAdapter.Fill|API> {0}, dataSet, srcTable, dataReader, startRecord, maxRecords", ObjectID); try { if (null == dataSet) { throw ADP.FillRequires(nameof(dataSet)); } if (string.IsNullOrEmpty(srcTable)) { throw ADP.FillRequiresSourceTableName(nameof(srcTable)); } if (null == dataReader) { throw ADP.FillRequires(nameof(dataReader)); } if (startRecord < 0) { throw ADP.InvalidStartRecord(nameof(startRecord), startRecord); } if (maxRecords < 0) { throw ADP.InvalidMaxRecords(nameof(maxRecords), maxRecords); } if (dataReader.IsClosed) { return(0); } // user must Close/Dispose of the dataReader DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes); return(FillFromReader(dataSet, null, srcTable, readerHandler, startRecord, maxRecords, null, null)); } finally { DataCommonEventSource.Log.ExitScope(logScopeId); } }
virtual protected int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords) // V1.2.3300, DbDataAdapter V1.0.3300 { IntPtr hscp; Bid.ScopeEnter(out hscp, "<comm.DataAdapter.Fill|API> %d#, dataSet, srcTable, dataReader, startRecord, maxRecords\n", ObjectID); try { if (null == dataSet) { throw ADP.FillRequires("dataSet"); } if (ADP.IsEmpty(srcTable)) { throw ADP.FillRequiresSourceTableName("srcTable"); } if (null == dataReader) { throw ADP.FillRequires("dataReader"); } if (startRecord < 0) { throw ADP.InvalidStartRecord("startRecord", startRecord); } if (maxRecords < 0) { throw ADP.InvalidMaxRecords("maxRecords", maxRecords); } if (dataReader.IsClosed) { return(0); } // user must Close/Dispose of the dataReader DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes); return(FillFromReader(dataSet, null, srcTable, readerHandler, startRecord, maxRecords, null, null)); } finally { Bid.ScopeLeave(ref hscp); } }
private bool FillNextResult(DataReaderContainer dataReader) { bool flag = true; if (this._hasFillErrorHandler) { try { flag = dataReader.NextResult(); } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionForCapture(exception); this.OnFillErrorHandler(exception, null, null); } return(flag); } return(dataReader.NextResult()); }
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); }
internal int FillFromReader(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int startRecord, int maxRecords, DataColumn parentChapterColumn, object parentChapterValue) { int num2 = 0; int schemaCount = 0; do { if (0 < dataReader.FieldCount) { SchemaMapping mapping = this.FillMapping(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue); schemaCount++; if (((mapping != null) && (mapping.DataValues != null)) && (mapping.DataTable != null)) { mapping.DataTable.BeginLoadData(); try { if ((1 == schemaCount) && ((0 < startRecord) || (0 < maxRecords))) { num2 = this.FillLoadDataRowChunk(mapping, startRecord, maxRecords); } else { int num3 = this.FillLoadDataRow(mapping); if (1 == schemaCount) { num2 = num3; } } } finally { mapping.DataTable.EndLoadData(); } if (datatable != null) { return(num2); } } } }while (this.FillNextResult(dataReader)); return(num2); }
protected virtual int Fill(DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords) { int num3; IntPtr ptr; Bid.ScopeEnter(out ptr, "<comm.DataAdapter.Fill|API> %d#, dataTables[], dataReader, startRecord, maxRecords\n", this.ObjectID); try { ADP.CheckArgumentLength(dataTables, "tables"); if (((dataTables == null) || (dataTables.Length == 0)) || (dataTables[0] == null)) { throw ADP.FillRequires("dataTable"); } if (dataReader == null) { throw ADP.FillRequires("dataReader"); } if ((1 < dataTables.Length) && ((startRecord != 0) || (maxRecords != 0))) { throw ADP.NotSupported(); } int num2 = 0; bool enforceConstraints = false; DataSet dataSet = dataTables[0].DataSet; try { if (dataSet != null) { enforceConstraints = dataSet.EnforceConstraints; dataSet.EnforceConstraints = false; } for (int i = 0; i < dataTables.Length; i++) { if (dataReader.IsClosed) { goto Label_00DE; } DataReaderContainer container = DataReaderContainer.Create(dataReader, this.ReturnProviderSpecificTypes); if (container.FieldCount > 0) { if ((0 < i) && !this.FillNextResult(container)) { goto Label_00DE; } int num4 = this.FillFromReader(null, dataTables[i], null, container, startRecord, maxRecords, null, null); if (i == 0) { num2 = num4; } } } } catch (ConstraintException) { enforceConstraints = false; throw; } finally { if (enforceConstraints) { dataSet.EnforceConstraints = true; } } Label_00DE: num3 = num2; } finally { Bid.ScopeLeave(ref ptr); } return(num3); }
protected virtual int Fill(DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords) { long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DataAdapter.Fill|API> {0}, dataTables[], dataReader, startRecord, maxRecords", ObjectID); try { ADP.CheckArgumentLength(dataTables, nameof(dataTables)); if ((null == dataTables) || (0 == dataTables.Length) || (null == dataTables[0])) { throw ADP.FillRequires("dataTable"); } if (null == dataReader) { throw ADP.FillRequires(nameof(dataReader)); } if ((1 < dataTables.Length) && ((0 != startRecord) || (0 != maxRecords))) { throw ADP.NotSupported(); // FillChildren is not supported with FillPage } int result = 0; bool enforceContraints = false; DataSet commonDataSet = dataTables[0].DataSet; try { if (null != commonDataSet) { enforceContraints = commonDataSet.EnforceConstraints; commonDataSet.EnforceConstraints = false; } for (int i = 0; i < dataTables.Length; ++i) { Debug.Assert(null != dataTables[i], "null DataTable Fill"); if (dataReader.IsClosed) { #if DEBUG Debug.Assert(!_debugHookNonEmptySelectCommand, "Debug hook asserts data reader should be open"); #endif break; } DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes); AssertReaderHandleFieldCount(readerHandler); if (readerHandler.FieldCount <= 0) { if (i == 0) { bool lastFillNextResult; do { lastFillNextResult = FillNextResult(readerHandler); }while (lastFillNextResult && readerHandler.FieldCount <= 0); if (!lastFillNextResult) { break; } } else { continue; } } if ((0 < i) && !FillNextResult(readerHandler)) { break; } // user must Close/Dispose of the dataReader // user will have to call NextResult to access remaining results int count = FillFromReader(null, dataTables[i], null, readerHandler, startRecord, maxRecords, null, null); if (0 == i) { result = count; } } } catch (ConstraintException) { enforceContraints = false; throw; } finally { if (enforceContraints) { commonDataSet.EnforceConstraints = true; } } return(result); } finally { DataCommonEventSource.Log.ExitScope(logScopeId); } }
internal int FillFromReader(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int startRecord, int maxRecords, DataColumn parentChapterColumn, object parentChapterValue) { int result = 0; int num = 0; do { if (0 < dataReader.FieldCount) { SchemeMap schemaMapping = this.FillMapping(dataset, datatable, srcTable, dataReader, num, parentChapterColumn, parentChapterValue); num++; if (schemaMapping != null && schemaMapping.DataValues != null && schemaMapping.DataTable != null) { schemaMapping.DataTable.BeginLoadData(); try { if (1 == num && (0 < startRecord || 0 < maxRecords)) { result = this.FillLoadDataRowChunk(schemaMapping, startRecord, maxRecords); } else { int num2 = this.FillLoadDataRow(schemaMapping); if (1 == num) { result = num2; } } } finally { schemaMapping.DataTable.EndLoadData(); } if (datatable != null) { break; } } } } while (dataReader.NextResult()); return result; }
private void AssertReaderHandleFieldCount(DataReaderContainer readerHandler) { #if DEBUG Debug.Assert(!_debugHookNonEmptySelectCommand || readerHandler.FieldCount > 0, "Scenario expects non-empty results but no fields reported by reader"); #endif }
private static void AssertReaderHandleFieldCount(DataReaderContainer readerHandler) { #if DEBUG Debug.Assert(readerHandler.FieldCount > 0, "Scenario expects non-empty results but no fields reported by reader"); #endif }
private SchemeMap FillMapping(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int schemaCount, DataColumn parentChapterColumn, object parentChapterValue) { bool keyInfo = MissingSchemaAction.AddWithKey == this.MissingSchemaAction; string sourceTableName = null; if (dataset != null) { sourceTableName = NativeDataAdapter.GetSourceTableName(srcTable, schemaCount); } return new SchemeMap(this, dataset, datatable, dataReader, keyInfo, SchemaType.Mapped, sourceTableName, true, parentChapterColumn, parentChapterValue); }
private SchemaMapping FillMapping(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int schemaCount, DataColumn parentChapterColumn, object parentChapterValue) { SchemaMapping mapping = null; if (this._hasFillErrorHandler) { try { mapping = this.FillMappingInternal(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue); } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionForCapture(exception); this.OnFillErrorHandler(exception, null, null); } return(mapping); } return(this.FillMappingInternal(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue)); }
internal int FillFromReader(DataSet?dataset, DataTable?datatable, string?srcTable, DataReaderContainer dataReader, int startRecord, int maxRecords) { return(FillFromReader(dataset, datatable, srcTable, dataReader, startRecord, maxRecords, null, null)); }
private int FillFromReaderLight(DataTable datatable, DataReaderContainer dataReader) { SchemeMap schemaMapping = this.FillMapping(datatable, dataReader); schemaMapping.DataTable.BeginLoadData(); int result = this.FillLoadDataRow(schemaMapping); schemaMapping.DataTable.EndLoadData(); return result; }
private SchemaMapping FillMappingInternal(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int schemaCount, DataColumn parentChapterColumn, object parentChapterValue) { bool withKeyInfo = (Data.MissingSchemaAction.AddWithKey == MissingSchemaAction); string tmp = null; if (null != dataset) { tmp = DataAdapter.GetSourceTableName(srcTable, schemaCount); } return(new SchemaMapping(this, dataset, datatable, dataReader, withKeyInfo, SchemaType.Mapped, tmp, true, parentChapterColumn, parentChapterValue)); }
private SchemaMapping FillMappingInternal(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int schemaCount, DataColumn parentChapterColumn, object parentChapterValue) { bool keyInfo = System.Data.MissingSchemaAction.AddWithKey == this.MissingSchemaAction; string sourceTableName = null; if (dataset != null) { sourceTableName = GetSourceTableName(srcTable, schemaCount); } return(new SchemaMapping(this, dataset, datatable, dataReader, keyInfo, SchemaType.Mapped, sourceTableName, true, parentChapterColumn, parentChapterValue)); }
private SchemaMapping FillMapping(DataSet dataset, DataTable datatable, string srcTable, DataReaderContainer dataReader, int schemaCount, DataColumn parentChapterColumn, object parentChapterValue) { SchemaMapping mapping = null; if (_hasFillErrorHandler) { try { // only try-catch if a FillErrorEventHandler is registered so that // in the default case we get the full callstack from users mapping = FillMappingInternal(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue); } catch (Exception e) when(ADP.IsCatchableExceptionType(e)) { ADP.TraceExceptionForCapture(e); OnFillErrorHandler(e, null, null); } } else { mapping = FillMappingInternal(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue); } return(mapping); }
private SchemeMap FillMapping(DataTable datatable, DataReaderContainer dataReader) { return new SchemeMap(this, null, datatable, dataReader, false, SchemaType.Mapped, null, true, null, null); }