Пример #1
0
        static internal DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
        { // MDAC 60609
            DataColumn sortindex = dataTable.Columns[SchemaMappingUnsortedIndex];

            if (null == sortindex)
            {                                                                          // WebData 100390
                sortindex = new DataColumn(SchemaMappingUnsortedIndex, typeof(Int32)); // MDAC 67050
                dataTable.Columns.Add(sortindex);
            }
            int count = dataTable.Rows.Count;

            for (int i = 0; i < count; ++i)
            {
                dataTable.Rows[i][sortindex] = i;
            }
            ;
            DbSchemaTable schemaTable = new DbSchemaTable(dataTable, returnProviderSpecificTypes);

            const DataViewRowState rowStates = DataViewRowState.Unchanged | DataViewRowState.Added | DataViewRowState.ModifiedCurrent;

            DataRow[] dataRows = dataTable.Select(null, "ColumnOrdinal ASC", rowStates);
            Debug.Assert(null != dataRows, "GetSchemaRows: unexpected null dataRows");

            DbSchemaRow[] schemaRows = new DbSchemaRow[dataRows.Length];

            for (int i = 0; i < dataRows.Length; ++i)
            {
                schemaRows[i] = new DbSchemaRow(schemaTable, dataRows[i]);
            }
            return(schemaRows);
        }
Пример #2
0
 internal DbSchemaRow(DbSchemaTable schemaTable, DataRow dataRow)
 {
     this.schemaTable = schemaTable;
     this.dataRow     = dataRow;
 }