Пример #1
0
        private void FillSchemaTable(DataTable schemaTable)
        {
            DataColumn column3 = new DataColumn(SchemaTableOptionalColumn.ProviderSpecificDataType, typeof(Type));

            schemaTable.Columns.Add(column3);
            int fieldCount = this.FieldCount;
            DbSqlParserColumnCollection columns = null;
            int count = 0;

            if (this._keyInfoRequested)
            {
                OracleSqlParser parser = new OracleSqlParser();
                parser.Parse(this._statementText, this._connection);
                columns = parser.Columns;
                count   = columns.Count;
            }
            for (int i = 0; i < fieldCount; i++)
            {
                OracleColumn column = this._columnInfo[i];
                DataRow      row    = schemaTable.NewRow();
                row[SchemaTableColumn.ColumnName]    = column.ColumnName;
                row[SchemaTableColumn.ColumnOrdinal] = column.Ordinal;
                if (column.IsLong | column.IsLob)
                {
                    row[SchemaTableColumn.ColumnSize] = 0x7fffffff;
                }
                else
                {
                    row[SchemaTableColumn.ColumnSize] = column.SchemaTableSize;
                }
                row[SchemaTableColumn.NumericPrecision] = column.Precision;
                row[SchemaTableColumn.NumericScale]     = column.Scale;
                row[SchemaTableColumn.DataType]         = column.GetFieldType();
                row[column3] = column.GetFieldOracleType();
                row[SchemaTableColumn.ProviderType] = column.OracleType;
                row[SchemaTableColumn.IsLong]       = column.IsLong | column.IsLob;
                row[SchemaTableColumn.AllowDBNull]  = column.IsNullable;
                if (this._keyInfoRequested && (count == fieldCount))
                {
                    DbSqlParserColumn column2 = columns[i];
                    row[SchemaTableColumn.IsAliased]      = column2.IsAliased;
                    row[SchemaTableColumn.IsExpression]   = column2.IsExpression;
                    row[SchemaTableColumn.IsKey]          = column2.IsKey;
                    row[SchemaTableColumn.IsUnique]       = column2.IsUnique;
                    row[SchemaTableColumn.BaseSchemaName] = this.SetSchemaValue(OracleSqlParser.CatalogCase(column2.SchemaName));
                    row[SchemaTableColumn.BaseTableName]  = this.SetSchemaValue(OracleSqlParser.CatalogCase(column2.TableName));
                    row[SchemaTableColumn.BaseColumnName] = this.SetSchemaValue(OracleSqlParser.CatalogCase(column2.ColumnName));
                }
                else
                {
                    row[SchemaTableColumn.IsAliased]      = DBNull.Value;
                    row[SchemaTableColumn.IsExpression]   = DBNull.Value;
                    row[SchemaTableColumn.IsKey]          = DBNull.Value;
                    row[SchemaTableColumn.IsUnique]       = DBNull.Value;
                    row[SchemaTableColumn.BaseSchemaName] = DBNull.Value;
                    row[SchemaTableColumn.BaseTableName]  = DBNull.Value;
                    row[SchemaTableColumn.BaseColumnName] = DBNull.Value;
                }
                schemaTable.Rows.Add(row);
                row.AcceptChanges();
            }
        }