internal SchemaMapping(DataAdapter adapter, DataSet dataset, System.Data.DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue) { MissingMappingAction missingMappingAction; MissingSchemaAction missingSchemaAction; this._dataSet = dataset; this._dataTable = datatable; this._adapter = adapter; this._dataReader = dataReader; if (keyInfo) { this._schemaTable = dataReader.GetSchemaTable(); } if (adapter.ShouldSerializeFillLoadOption()) { this._loadOption = adapter.FillLoadOption; } else if (adapter.AcceptChangesDuringFill) { this._loadOption = (LoadOption) 4; } else { this._loadOption = (LoadOption) 5; } if (SchemaType.Mapped == schemaType) { missingMappingAction = this._adapter.MissingMappingAction; missingSchemaAction = this._adapter.MissingSchemaAction; if (ADP.IsEmpty(sourceTableName)) { if (this._dataTable != null) { int num2 = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 == num2) { switch (missingMappingAction) { case MissingMappingAction.Passthrough: this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); goto Label_01DB; case MissingMappingAction.Ignore: this._tableMapping = null; goto Label_01DB; case MissingMappingAction.Error: throw ADP.MissingTableMappingDestination(this._dataTable.TableName); } throw ADP.InvalidMissingMappingAction(missingMappingAction); } this._tableMapping = this._adapter.TableMappings[num2]; } } else { this._tableMapping = this._adapter.GetTableMappingBySchemaAction(sourceTableName, sourceTableName, missingMappingAction); } } else { if (SchemaType.Source != schemaType) { throw ADP.InvalidSchemaType(schemaType); } missingMappingAction = MissingMappingAction.Passthrough; missingSchemaAction = MissingSchemaAction.Add; if (!ADP.IsEmpty(sourceTableName)) { this._tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, missingMappingAction); } else if (this._dataTable != null) { int num = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 != num) { this._tableMapping = this._adapter.TableMappings[num]; } else { this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); } } } Label_01DB: if (this._tableMapping != null) { if (this._dataTable == null) { this._dataTable = this._tableMapping.GetDataTableBySchemaAction(this._dataSet, missingSchemaAction); } if (this._dataTable != null) { this._fieldNames = GenerateFieldNames(dataReader); if (this._schemaTable == null) { this._readerDataValues = this.SetupSchemaWithoutKeyInfo(missingMappingAction, missingSchemaAction, gettingData, parentChapterColumn, parentChapterValue); return; } this._readerDataValues = this.SetupSchemaWithKeyInfo(missingMappingAction, missingSchemaAction, gettingData, parentChapterColumn, parentChapterValue); } } }
internal SchemaMapping(DataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue) { Debug.Assert(null != adapter, "adapter"); Debug.Assert(null != dataReader, "dataReader"); Debug.Assert(0 < dataReader.FieldCount, "FieldCount"); Debug.Assert(null != dataset || null != datatable, "SchemaMapping - null dataSet"); Debug.Assert(SchemaType.Mapped == schemaType || SchemaType.Source == schemaType, "SetupSchema - invalid schemaType"); _dataSet = dataset; // setting DataSet implies chapters are supported _dataTable = datatable; // setting only DataTable, not DataSet implies chapters are not supported _adapter = adapter; _dataReader = dataReader; if (keyInfo) { _schemaTable = dataReader.GetSchemaTable(); } if (adapter.ShouldSerializeFillLoadOption()) { _loadOption = adapter.FillLoadOption; } else if (adapter.AcceptChangesDuringFill) { _loadOption = (LoadOption)4; // true } else { _loadOption = (LoadOption)5; //false } MissingMappingAction mappingAction; MissingSchemaAction schemaAction; if (SchemaType.Mapped == schemaType) { mappingAction = _adapter.MissingMappingAction; schemaAction = _adapter.MissingSchemaAction; if (!ADP.IsEmpty(sourceTableName)) { // MDAC 66034 _tableMapping = _adapter.GetTableMappingBySchemaAction(sourceTableName, sourceTableName, mappingAction); } else if (null != _dataTable) { int index = _adapter.IndexOfDataSetTable(_dataTable.TableName); if (-1 != index) { _tableMapping = _adapter.TableMappings[index]; } else { switch (mappingAction) { case MissingMappingAction.Passthrough: _tableMapping = new DataTableMapping(_dataTable.TableName, _dataTable.TableName); break; case MissingMappingAction.Ignore: _tableMapping = null; break; case MissingMappingAction.Error: throw ADP.MissingTableMappingDestination(_dataTable.TableName); default: throw ADP.InvalidMissingMappingAction(mappingAction); } } } } else if (SchemaType.Source == schemaType) { mappingAction = System.Data.MissingMappingAction.Passthrough; schemaAction = Data.MissingSchemaAction.Add; if (!ADP.IsEmpty(sourceTableName)) { // MDAC 66034 _tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, mappingAction); } else if (null != _dataTable) { int index = _adapter.IndexOfDataSetTable(_dataTable.TableName); // MDAC 66034 if (-1 != index) { _tableMapping = _adapter.TableMappings[index]; } else { _tableMapping = new DataTableMapping(_dataTable.TableName, _dataTable.TableName); } } } else { throw ADP.InvalidSchemaType(schemaType); } if (null != _tableMapping) { if (null == _dataTable) { _dataTable = _tableMapping.GetDataTableBySchemaAction(_dataSet, schemaAction); } if (null != _dataTable) { _fieldNames = GenerateFieldNames(dataReader); if (null == _schemaTable) { _readerDataValues = SetupSchemaWithoutKeyInfo(mappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue); } else { _readerDataValues = SetupSchemaWithKeyInfo(mappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue); } } // else (null == _dataTable) which means ignore (mapped to nothing) } }
internal SchemaMapping(DataAdapter adapter, DataSet dataset, System.Data.DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue) { MissingMappingAction missingMappingAction; MissingSchemaAction missingSchemaAction; this._dataSet = dataset; this._dataTable = datatable; this._adapter = adapter; this._dataReader = dataReader; if (keyInfo) { this._schemaTable = dataReader.GetSchemaTable(); } if (adapter.ShouldSerializeFillLoadOption()) { this._loadOption = adapter.FillLoadOption; } else if (adapter.AcceptChangesDuringFill) { this._loadOption = (LoadOption)4; } else { this._loadOption = (LoadOption)5; } if (SchemaType.Mapped == schemaType) { missingMappingAction = this._adapter.MissingMappingAction; missingSchemaAction = this._adapter.MissingSchemaAction; if (ADP.IsEmpty(sourceTableName)) { if (this._dataTable != null) { int num2 = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 == num2) { switch (missingMappingAction) { case MissingMappingAction.Passthrough: this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); goto Label_01DB; case MissingMappingAction.Ignore: this._tableMapping = null; goto Label_01DB; case MissingMappingAction.Error: throw ADP.MissingTableMappingDestination(this._dataTable.TableName); } throw ADP.InvalidMissingMappingAction(missingMappingAction); } this._tableMapping = this._adapter.TableMappings[num2]; } } else { this._tableMapping = this._adapter.GetTableMappingBySchemaAction(sourceTableName, sourceTableName, missingMappingAction); } } else { if (SchemaType.Source != schemaType) { throw ADP.InvalidSchemaType(schemaType); } missingMappingAction = MissingMappingAction.Passthrough; missingSchemaAction = MissingSchemaAction.Add; if (!ADP.IsEmpty(sourceTableName)) { this._tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, missingMappingAction); } else if (this._dataTable != null) { int num = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 != num) { this._tableMapping = this._adapter.TableMappings[num]; } else { this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); } } } Label_01DB: if (this._tableMapping != null) { if (this._dataTable == null) { this._dataTable = this._tableMapping.GetDataTableBySchemaAction(this._dataSet, missingSchemaAction); } if (this._dataTable != null) { this._fieldNames = GenerateFieldNames(dataReader); if (this._schemaTable == null) { this._readerDataValues = this.SetupSchemaWithoutKeyInfo(missingMappingAction, missingSchemaAction, gettingData, parentChapterColumn, parentChapterValue); return; } this._readerDataValues = this.SetupSchemaWithKeyInfo(missingMappingAction, missingSchemaAction, gettingData, parentChapterColumn, parentChapterValue); } } }