Пример #1
0
        protected override void FillViewColumns(DBSchemaViewColumnCollection aview, DataTable dtColumns)
        {
            DataColumn autoinc            = GetColumn(dtColumns, "IsAutoIncrement", true);
            DataColumn colname            = GetColumn(dtColumns, "ColumnName", true);
            DataColumn ispk               = GetColumn(dtColumns, "IsKey", true);
            DataColumn isRO               = GetColumn(dtColumns, "IsReadOnly", true);
            DataColumn type               = GetColumn(dtColumns, "DataType", true);
            DataColumn allownull          = GetColumn(dtColumns, "AllowDBNull", true);
            DataColumn pos                = GetColumn(dtColumns, "ColumnOrdinal", true);
            DataColumn size               = GetColumn(dtColumns, "ColumnSize", true);
            DataColumn dataType           = GetColumn(dtColumns, "DataTypeName", true);
            DataColumn CharacterSetColumn = GetColumn(dtColumns, "CHARACTER_SET_NAME", false);

            foreach (DataRow coldef in dtColumns.Rows)
            {
                DBSchemaViewColumn tcol = new DBSchemaViewColumn();
                tcol.Name            = GetColumnStringValue(coldef, colname);
                tcol.HasDefault      = false;
                tcol.Nullable        = GetColumnBoolValue(coldef, allownull);
                tcol.OrdinalPosition = GetColumnIntValue(coldef, pos);
                tcol.ReadOnly        = GetColumnBoolValue(coldef, isRO);
                tcol.Size            = GetColumnIntValue(coldef, size);
                tcol.Type            = Type.GetType(GetColumnStringValue(coldef, type));
                tcol.DbType          = this.GetDbTypeForNativeType(GetColumnStringValue(coldef, dataType), GetColumnStringValue(coldef, CharacterSetColumn));

                aview.Add(tcol);
            }
        }
Пример #2
0
        protected override void FillViewColumns(DBSchemaViewColumnCollection aview, DataTable dtColumns)
        {
            DataColumn TableNameColumn          = GetColumn(dtColumns, "TABLE_NAME", true);
            DataColumn TableSchemaColumn        = GetColumn(dtColumns, "OWNER", false);
            DataColumn TableCatalogColumn       = GetColumn(dtColumns, "TABLE_CATALOG", false);
            DataColumn ColumnNameColumn         = GetColumn(dtColumns, "COLUMN_NAME", true);
            DataColumn OrdinalPositionColumn    = GetColumn(dtColumns, "ID", true);
            DataColumn DefaultValueColumn       = GetColumn(dtColumns, "COLUMN_DEFAULT", false);
            DataColumn IsNullableColumn         = GetColumn(dtColumns, "NULLABLE", true);
            DataColumn DataTypeColumn           = GetColumn(dtColumns, "DATATYPE", true);
            DataColumn MaxCharacterLengthColumn = GetColumn(dtColumns, "LENGTH", false);
            DataColumn AutoNumberColumn         = GetColumn(dtColumns, "AUTOINCREMENT", false);
            DataColumn PrimaryKeyColumn         = GetColumn(dtColumns, "PRIMARY_KEY", false);
            DataColumn CharacterSetColumn       = GetColumn(dtColumns, "CHARACTER_SET_NAME", false);

            foreach (DataRow row in dtColumns.Rows)
            {
                DBSchemaViewColumn col = new DBSchemaViewColumn();
                col.Name            = GetColumnStringValue(row, ColumnNameColumn);
                col.OrdinalPosition = GetColumnIntValue(row, OrdinalPositionColumn);
                col.DefaultValue    = GetColumnStringValue(row, DefaultValueColumn);
                col.Nullable        = GetColumnBoolValue(row, IsNullableColumn);
                col.NativeType      = GetColumnStringValue(row, DataTypeColumn);
                col.DbType          = GetDbTypeForNativeType(col.NativeType, GetColumnStringValue(row, CharacterSetColumn));
                col.Type            = GetSystemTypeForNativeType(GetColumnStringValue(row, DataTypeColumn));
                col.Size            = GetColumnIntValue(row, MaxCharacterLengthColumn);
                col.HasDefault      = !string.IsNullOrEmpty(col.DefaultValue);

                aview.Add(col);
            }
        }
Пример #3
0
        /// <summary>
        /// Fills the view info with the meta data Columns info
        /// </summary>
        /// <param name="aview"></param>
        /// <param name="dtColumns"></param>
        protected override void FillViewColumns(DBSchemaViewColumnCollection aview, DataTable dtColumns)
        {
            DataColumn ColumnNameColumn         = GetColumn(dtColumns, "COLUMN_NAME", true);
            DataColumn OrdinalPositionColumn    = GetColumn(dtColumns, "ORDINAL_POSITION", true);
            DataColumn DefaultValueColumn       = GetColumn(dtColumns, "COLUMN_HASDEFAULT", false);
            DataColumn IsNullableColumn         = GetColumn(dtColumns, "IS_NULLABLE", true);
            DataColumn DataTypeColumn           = GetColumn(dtColumns, "DATA_TYPE", true);
            DataColumn MaxCharacterLengthColumn = GetColumn(dtColumns, "CHARACTER_MAXIMUM_LENGTH", false);
            DataColumn IsReadOnly = GetColumn(dtColumns, "ISREADONLY", false);

            foreach (DataRow row in dtColumns.Rows)
            {
                DBSchemaViewColumn col = new DBSchemaViewColumn();
                col.Name            = GetColumnStringValue(row, ColumnNameColumn);
                col.OrdinalPosition = GetColumnIntValue(row, OrdinalPositionColumn);
                col.DefaultValue    = GetColumnStringValue(row, DefaultValueColumn);
                col.Nullable        = GetColumnBoolValue(row, IsNullableColumn);
                int type = GetColumnIntValue(row, DataTypeColumn, -1);
                DBMSAccessTypeMapping map = null;
                if (type > 0 && this.Types.TryGetType(type, out map))
                {
                    col.NativeType = map.TypeName;
                    col.DbType     = GetDbTypeForNativeType(map.TypeName, string.Empty);
                    if (null == map.RuntimeType)
                    {
                        col.Type = GetSystemTypeForNativeType(map.TypeName);
                    }
                    else
                    {
                        col.Type = map.RuntimeType;
                        if (col.DbType == DbType.Object)
                        {
                            col.DbType = DBHelper.GetDBTypeForRuntimeType(col.Type);
                        }
                    }
                }
                col.Size       = GetColumnIntValue(row, MaxCharacterLengthColumn);
                col.ReadOnly   = GetColumnBoolValue(row, IsReadOnly);
                col.HasDefault = GetColumnBoolValue(row, DefaultValueColumn);

                aview.Add(col);
            }
        }