Ejemplo n.º 1
0
        private static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
        {
            DataColumn column = dataTable.Columns[SchemaMappingUnsortedIndex];
            if (column == null)
            {
                column = new DataColumn(SchemaMappingUnsortedIndex, typeof (int));
                dataTable.Columns.Add(column);
            }

            int count = dataTable.Rows.Count;
            for (int index = 0; index < count; ++index)
            {
                dataTable.Rows[index][column] = index;
            }
            
            var schemaTable = new DbSchemaTable(dataTable, returnProviderSpecificTypes);
            DataRow[] dataRowArray = dataTable.Select(null, "ColumnOrdinal ASC", DataViewRowState.CurrentRows);
            
            var dbSchemaRowArray = new DbSchemaRow[dataRowArray.Length];
            for (int index = 0; index < dataRowArray.Length; ++index)
            {
                dbSchemaRowArray[index] = new DbSchemaRow(schemaTable, dataRowArray[index]);
            }
            
            return dbSchemaRowArray;
        }
Ejemplo n.º 2
0
        private static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
        {
            DataColumn column = dataTable.Columns[SchemaMappingUnsortedIndex];

            if (column == null)
            {
                column = new DataColumn(SchemaMappingUnsortedIndex, typeof(int));
                dataTable.Columns.Add(column);
            }

            int count = dataTable.Rows.Count;

            for (int index = 0; index < count; ++index)
            {
                dataTable.Rows[index][column] = index;
            }

            var schemaTable = new DbSchemaTable(dataTable, returnProviderSpecificTypes);

            DataRow[] dataRowArray = dataTable.Select(null, "ColumnOrdinal ASC", DataViewRowState.CurrentRows);

            var dbSchemaRowArray = new DbSchemaRow[dataRowArray.Length];

            for (int index = 0; index < dataRowArray.Length; ++index)
            {
                dbSchemaRowArray[index] = new DbSchemaRow(schemaTable, dataRowArray[index]);
            }

            return(dbSchemaRowArray);
        }