internal static DBMSAccessTypeMappingCollection LoadFromTable(System.Data.DataTable dt) { DBMSAccessTypeMappingCollection col = new DBMSAccessTypeMappingCollection(); DataColumn provtype = Schema.DBSchemaProvider.GetColumn(dt, "ProviderDbType", true); DataColumn name = Schema.DBSchemaProvider.GetColumn(dt, "TypeName", true); DataColumn runtime = Schema.DBSchemaProvider.GetColumn(dt, "DataType", true); DataColumn native = Schema.DBSchemaProvider.GetColumn(dt, "NativeDataType", true); foreach (DataRow row in dt.Rows) { DBMSAccessTypeMapping map = new DBMSAccessTypeMapping(); map.NativeType = Schema.DBSchemaProvider.GetColumnIntValue(row, native); map.TypeName = Schema.DBSchemaProvider.GetColumnStringValue(row, name); map.ProviderType = Schema.DBSchemaProvider.GetColumnIntValue(row, provtype); string type = Schema.DBSchemaProvider.GetColumnStringValue(row, runtime); if (!string.IsNullOrEmpty(type)) { map.RuntimeType = Type.GetType(type, false); } col.Add(map); } return(col); }
/// <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); } }