Пример #1
0
 internal SchemeMap(NativeDataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue)
 {
     this._dataSet = dataset;
     this._dataTable = datatable;
     this._adapter = adapter;
     this._dataReader = dataReader;
     if (keyInfo)
     {
         this._schemaTable = dataReader.GetSchemaTable();
     }
  
     MissingMappingAction missingMappingAction;
     MissingSchemaAction schemaAction;
     if (SchemaType.Mapped == schemaType)
     {
         missingMappingAction = this._adapter.MissingMappingAction;
         schemaAction = this._adapter.MissingSchemaAction;
         if (!string.IsNullOrEmpty(sourceTableName))
         {
             this._tableMapping = this._adapter.GetTableMappingBySchemaAction(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
                 {
                     switch (missingMappingAction)
                     {
                         case MissingMappingAction.Passthrough:
                             this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName);
                             break;
                         case MissingMappingAction.Ignore:
                             this._tableMapping = null;
                             break;
                         case MissingMappingAction.Error:
                             throw new Exception("MissingTableMappingDestination");
                         default:
                             throw new Exception("InvalidMissingMappingAction");
                     }
                 }
             }
         }
     }
     else
     {
         if (SchemaType.Source != schemaType)
         {
             throw new Exception();
         }
         missingMappingAction = MissingMappingAction.Passthrough;
         schemaAction = MissingSchemaAction.Add;
         if (!string.IsNullOrEmpty(sourceTableName))
         {
             this._tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, missingMappingAction);
         }
         else
         {
             if (this._dataTable != null)
             {
                 int num2 = this._adapter.IndexOfDataSetTable(this._dataTable.TableName);
                 if (-1 != num2)
                 {
                     this._tableMapping = this._adapter.TableMappings[num2];
                 }
                 else
                 {
                     this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName);
                 }
             }
         }
     }
     if (this._tableMapping != null)
     {
         if (this._dataTable == null)
         {
             this._dataTable = this._tableMapping.GetDataTableBySchemaAction(this._dataSet, schemaAction);
         }
         if (this._dataTable != null)
         {
             this._fieldNames = SchemeMap.GenerateFieldNames(dataReader);
             if (this._schemaTable == null)
             {
                 this._readerDataValues = this.SetupSchemaWithoutKeyInfo(missingMappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue);
                 return;
             }
             this._readerDataValues = this.SetupSchemaWithKeyInfo(missingMappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue);
         }
     }
 }
Пример #2
0
 private static string[] GenerateFieldNames(DataReaderContainer dataReader)
 {
     string[] array = new string[dataReader.FieldCount];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = dataReader.GetName(i);
     }
     BuildSchemaTableInfoTableNames(array);
     return array;
 }