1
1
using System ;
2
+ using System . Globalization ;
3
+ using MySql . Data . MySqlClient . Types ;
2
4
using MySql . Data . Serialization ;
3
5
4
6
#if ! NETSTANDARD1_3 && ! NETSTANDARD2_0
@@ -38,8 +40,11 @@ namespace MySql.Data.MySqlClient
38
40
{
39
41
public sealed class MySqlDbColumn : System . Data . Common . DbColumn
40
42
{
41
- internal MySqlDbColumn ( int ordinal , ColumnDefinitionPayload column , Type type , string dataTypeName )
43
+ internal MySqlDbColumn ( int ordinal , ColumnDefinitionPayload column , MySqlDbType mySqlDbType )
42
44
{
45
+ var columnTypeMapping = TypeMapper . Mapper . GetColumnMapping ( mySqlDbType ) ;
46
+
47
+ var type = columnTypeMapping . DbTypeMapping . ClrType ;
43
48
var columnSize = type == typeof ( string ) || type == typeof ( Guid ) ?
44
49
column . ColumnLength / SerializationUtility . GetBytesPerCharacter ( column . CharacterSet ) :
45
50
column . ColumnLength ;
@@ -53,7 +58,9 @@ internal MySqlDbColumn(int ordinal, ColumnDefinitionPayload column, Type type, s
53
58
ColumnOrdinal = ordinal ;
54
59
ColumnSize = columnSize > int . MaxValue ? int . MaxValue : unchecked ( ( int ) columnSize ) ;
55
60
DataType = type ;
56
- DataTypeName = dataTypeName ;
61
+ DataTypeName = columnTypeMapping . SimpleDataTypeName ;
62
+ if ( mySqlDbType == MySqlDbType . String )
63
+ DataTypeName += string . Format ( CultureInfo . InvariantCulture , "({0})" , columnSize ) ;
57
64
IsAliased = column . PhysicalName != column . Name ;
58
65
IsAutoIncrement = ( column . ColumnFlags & ColumnFlags . AutoIncrement ) != 0 ;
59
66
IsExpression = false ;
@@ -72,9 +79,9 @@ internal MySqlDbColumn(int ordinal, ColumnDefinitionPayload column, Type type, s
72
79
NumericPrecision -- ;
73
80
}
74
81
NumericScale = column . Decimals ;
75
- ProviderType = ( int ) column . ColumnType ;
82
+ ProviderType = mySqlDbType ;
76
83
}
77
84
78
- public int ProviderType { get ; }
85
+ public MySqlDbType ProviderType { get ; }
79
86
}
80
87
}
0 commit comments