System.Data.Common.DbSchemaRow.GetSortedSchemaRows C# (CSharp) Метод

GetSortedSchemaRows() статический приватный Метод

static private GetSortedSchemaRows ( DataTable dataTable, bool returnProviderSpecificTypes ) : System.Data.Common.DbSchemaRow[]
dataTable System.Data.DataTable
returnProviderSpecificTypes bool
Результат System.Data.Common.DbSchemaRow[]
        internal static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
        {
            DataColumn sortindex = dataTable.Columns[SchemaMappingUnsortedIndex];
            if (null == sortindex)
            {
                sortindex = new DataColumn(SchemaMappingUnsortedIndex, typeof(int));
                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;
        }