@@ -20,18 +20,18 @@ private TypeMapper()
20
20
m_mySqlDbTypeToColumnTypeMetadata = [ ] ;
21
21
22
22
// boolean
23
- var typeBoolean = AddDbTypeMapping ( new ( typeof ( bool ) , [ DbType . Boolean ] , convert : static o => Convert . ToBoolean ( o , CultureInfo . InvariantCulture ) ) ) ;
23
+ var typeBoolean = AddDbTypeMapping ( new ( typeof ( bool ) , [ DbType . Boolean ] , convert : static o => Convert . ToBoolean ( o , CultureInfo . InvariantCulture ) ) ) ;
24
24
AddColumnTypeMetadata ( new ( "TINYINT" , typeBoolean , MySqlDbType . Bool , isUnsigned : false , length : 1 , columnSize : 1 , simpleDataTypeName : "BOOL" , createFormat : "BOOL" ) ) ;
25
25
26
26
// integers
27
- var typeSbyte = AddDbTypeMapping ( new ( typeof ( sbyte ) , [ DbType . SByte ] , convert : static o => Convert . ToSByte ( o , CultureInfo . InvariantCulture ) ) ) ;
28
- var typeByte = AddDbTypeMapping ( new ( typeof ( byte ) , [ DbType . Byte ] , convert : static o => Convert . ToByte ( o , CultureInfo . InvariantCulture ) ) ) ;
29
- var typeShort = AddDbTypeMapping ( new ( typeof ( short ) , [ DbType . Int16 ] , convert : static o => Convert . ToInt16 ( o , CultureInfo . InvariantCulture ) ) ) ;
30
- var typeUshort = AddDbTypeMapping ( new ( typeof ( ushort ) , [ DbType . UInt16 ] , convert : static o => Convert . ToUInt16 ( o , CultureInfo . InvariantCulture ) ) ) ;
31
- var typeInt = AddDbTypeMapping ( new ( typeof ( int ) , [ DbType . Int32 ] , convert : static o => Convert . ToInt32 ( o , CultureInfo . InvariantCulture ) ) ) ;
32
- var typeUint = AddDbTypeMapping ( new ( typeof ( uint ) , [ DbType . UInt32 ] , convert : static o => Convert . ToUInt32 ( o , CultureInfo . InvariantCulture ) ) ) ;
33
- var typeLong = AddDbTypeMapping ( new ( typeof ( long ) , [ DbType . Int64 ] , convert : static o => Convert . ToInt64 ( o , CultureInfo . InvariantCulture ) ) ) ;
34
- var typeUlong = AddDbTypeMapping ( new ( typeof ( ulong ) , [ DbType . UInt64 ] , convert : static o => Convert . ToUInt64 ( o , CultureInfo . InvariantCulture ) ) ) ;
27
+ var typeSbyte = AddDbTypeMapping ( new ( typeof ( sbyte ) , [ DbType . SByte ] , convert : static o => Convert . ToSByte ( o , CultureInfo . InvariantCulture ) ) ) ;
28
+ var typeByte = AddDbTypeMapping ( new ( typeof ( byte ) , [ DbType . Byte ] , convert : static o => Convert . ToByte ( o , CultureInfo . InvariantCulture ) ) ) ;
29
+ var typeShort = AddDbTypeMapping ( new ( typeof ( short ) , [ DbType . Int16 ] , convert : static o => Convert . ToInt16 ( o , CultureInfo . InvariantCulture ) ) ) ;
30
+ var typeUshort = AddDbTypeMapping ( new ( typeof ( ushort ) , [ DbType . UInt16 ] , convert : static o => Convert . ToUInt16 ( o , CultureInfo . InvariantCulture ) ) ) ;
31
+ var typeInt = AddDbTypeMapping ( new ( typeof ( int ) , [ DbType . Int32 ] , convert : static o => Convert . ToInt32 ( o , CultureInfo . InvariantCulture ) ) ) ;
32
+ var typeUint = AddDbTypeMapping ( new ( typeof ( uint ) , [ DbType . UInt32 ] , convert : static o => Convert . ToUInt32 ( o , CultureInfo . InvariantCulture ) ) ) ;
33
+ var typeLong = AddDbTypeMapping ( new ( typeof ( long ) , [ DbType . Int64 ] , convert : static o => Convert . ToInt64 ( o , CultureInfo . InvariantCulture ) ) ) ;
34
+ var typeUlong = AddDbTypeMapping ( new ( typeof ( ulong ) , [ DbType . UInt64 ] , convert : static o => Convert . ToUInt64 ( o , CultureInfo . InvariantCulture ) ) ) ;
35
35
AddColumnTypeMetadata ( new ( "TINYINT" , typeSbyte , MySqlDbType . Byte , isUnsigned : false ) ) ;
36
36
AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true , length : 1 ) ) ;
37
37
AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true ) ) ;
@@ -46,18 +46,18 @@ private TypeMapper()
46
46
AddColumnTypeMetadata ( new ( "BIT" , typeUlong , MySqlDbType . Bit ) ) ;
47
47
48
48
// decimals
49
- var typeDecimal = AddDbTypeMapping ( new ( typeof ( decimal ) , [ DbType . Decimal , DbType . Currency , DbType . VarNumeric ] , convert : static o => Convert . ToDecimal ( o , CultureInfo . InvariantCulture ) ) ) ;
50
- var typeDouble = AddDbTypeMapping ( new ( typeof ( double ) , [ DbType . Double ] , convert : static o => Convert . ToDouble ( o , CultureInfo . InvariantCulture ) ) ) ;
51
- var typeFloat = AddDbTypeMapping ( new ( typeof ( float ) , [ DbType . Single ] , convert : static o => Convert . ToSingle ( o , CultureInfo . InvariantCulture ) ) ) ;
49
+ var typeDecimal = AddDbTypeMapping ( new ( typeof ( decimal ) , [ DbType . Decimal , DbType . Currency , DbType . VarNumeric ] , convert : static o => Convert . ToDecimal ( o , CultureInfo . InvariantCulture ) ) ) ;
50
+ var typeDouble = AddDbTypeMapping ( new ( typeof ( double ) , [ DbType . Double ] , convert : static o => Convert . ToDouble ( o , CultureInfo . InvariantCulture ) ) ) ;
51
+ var typeFloat = AddDbTypeMapping ( new ( typeof ( float ) , [ DbType . Single ] , convert : static o => Convert . ToSingle ( o , CultureInfo . InvariantCulture ) ) ) ;
52
52
AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . NewDecimal , createFormat : "DECIMAL({0},{1});precision,scale" ) ) ;
53
53
AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . NewDecimal , isUnsigned : true , createFormat : "DECIMAL({0},{1}) UNSIGNED;precision,scale" ) ) ;
54
54
AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . Decimal ) ) ;
55
55
AddColumnTypeMetadata ( new ( "DOUBLE" , typeDouble , MySqlDbType . Double ) ) ;
56
56
AddColumnTypeMetadata ( new ( "FLOAT" , typeFloat , MySqlDbType . Float ) ) ;
57
57
58
58
// string
59
- var typeFixedString = AddDbTypeMapping ( new ( typeof ( string ) , [ DbType . StringFixedLength , DbType . AnsiStringFixedLength ] , convert : Convert . ToString ! ) ) ;
60
- var typeString = AddDbTypeMapping ( new ( typeof ( string ) , [ DbType . String , DbType . AnsiString , DbType . Xml ] , convert : Convert . ToString ! ) ) ;
59
+ var typeFixedString = AddDbTypeMapping ( new ( typeof ( string ) , [ DbType . StringFixedLength , DbType . AnsiStringFixedLength ] , convert : Convert . ToString ! ) ) ;
60
+ var typeString = AddDbTypeMapping ( new ( typeof ( string ) , [ DbType . String , DbType . AnsiString , DbType . Xml ] , convert : Convert . ToString ! ) ) ;
61
61
AddColumnTypeMetadata ( new ( "VARCHAR" , typeString , MySqlDbType . VarChar , createFormat : "VARCHAR({0});size" ) ) ;
62
62
AddColumnTypeMetadata ( new ( "VARCHAR" , typeString , MySqlDbType . VarString ) ) ;
63
63
AddColumnTypeMetadata ( new ( "CHAR" , typeFixedString , MySqlDbType . String , createFormat : "CHAR({0});size" ) ) ;
@@ -70,7 +70,7 @@ private TypeMapper()
70
70
AddColumnTypeMetadata ( new ( "JSON" , typeString , MySqlDbType . JSON ) ) ;
71
71
72
72
// binary
73
- var typeBinary = AddDbTypeMapping ( new ( typeof ( byte [ ] ) , [ DbType . Binary ] ) ) ;
73
+ var typeBinary = AddDbTypeMapping ( new ( typeof ( byte [ ] ) , [ DbType . Binary ] ) ) ;
74
74
AddColumnTypeMetadata ( new ( "BLOB" , typeBinary , MySqlDbType . Blob , binary : true , columnSize : ushort . MaxValue , simpleDataTypeName : "BLOB" ) ) ;
75
75
AddColumnTypeMetadata ( new ( "BINARY" , typeBinary , MySqlDbType . Binary , binary : true , simpleDataTypeName : "BLOB" , createFormat : "BINARY({0});length" ) ) ;
76
76
AddColumnTypeMetadata ( new ( "VARBINARY" , typeBinary , MySqlDbType . VarBinary , binary : true , simpleDataTypeName : "BLOB" , createFormat : "VARBINARY({0});length" ) ) ;
@@ -91,15 +91,15 @@ private TypeMapper()
91
91
92
92
// date/time
93
93
#if NET6_0_OR_GREATER
94
- AddDbTypeMapping ( new ( typeof ( DateOnly ) , [ DbType . Date ] ) ) ;
94
+ AddDbTypeMapping ( new ( typeof ( DateOnly ) , [ DbType . Date ] ) ) ;
95
95
#endif
96
- var typeDate = AddDbTypeMapping ( new ( typeof ( DateTime ) , [ DbType . Date ] ) ) ;
97
- var typeDateTime = AddDbTypeMapping ( new ( typeof ( DateTime ) , [ DbType . DateTime , DbType . DateTime2 , DbType . DateTimeOffset ] ) ) ;
98
- AddDbTypeMapping ( new ( typeof ( DateTimeOffset ) , [ DbType . DateTimeOffset ] ) ) ;
96
+ var typeDate = AddDbTypeMapping ( new ( typeof ( DateTime ) , [ DbType . Date ] ) ) ;
97
+ var typeDateTime = AddDbTypeMapping ( new ( typeof ( DateTime ) , [ DbType . DateTime , DbType . DateTime2 , DbType . DateTimeOffset ] ) ) ;
98
+ AddDbTypeMapping ( new ( typeof ( DateTimeOffset ) , [ DbType . DateTimeOffset ] ) ) ;
99
99
#if NET6_0_OR_GREATER
100
- AddDbTypeMapping ( new ( typeof ( TimeOnly ) , [ DbType . Time ] ) ) ;
100
+ AddDbTypeMapping ( new ( typeof ( TimeOnly ) , [ DbType . Time ] ) ) ;
101
101
#endif
102
- var typeTime = AddDbTypeMapping ( new ( typeof ( TimeSpan ) , [ DbType . Time ] , convert : static o => o is string s ? Utility . ParseTimeSpan ( Encoding . UTF8 . GetBytes ( s ) ) : Convert . ChangeType ( o , typeof ( TimeSpan ) , CultureInfo . InvariantCulture ) ) ) ;
102
+ var typeTime = AddDbTypeMapping ( new ( typeof ( TimeSpan ) , [ DbType . Time ] , convert : static o => o is string s ? Utility . ParseTimeSpan ( Encoding . UTF8 . GetBytes ( s ) ) : Convert . ChangeType ( o , typeof ( TimeSpan ) , CultureInfo . InvariantCulture ) ) ) ;
103
103
AddColumnTypeMetadata ( new ( "DATETIME" , typeDateTime , MySqlDbType . DateTime ) ) ;
104
104
AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Date ) ) ;
105
105
AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Newdate ) ) ;
@@ -113,11 +113,11 @@ private TypeMapper()
113
113
#else
114
114
Func < object , object > convertGuid = static o => Guid . Parse ( Convert . ToString ( o , CultureInfo . InvariantCulture ) ! ) ;
115
115
#endif
116
- var typeGuid = AddDbTypeMapping ( new ( typeof ( Guid ) , [ DbType . Guid ] , convert : convertGuid ) ) ;
116
+ var typeGuid = AddDbTypeMapping ( new ( typeof ( Guid ) , [ DbType . Guid ] , convert : convertGuid ) ) ;
117
117
AddColumnTypeMetadata ( new ( "CHAR" , typeGuid , MySqlDbType . Guid , length : 36 , simpleDataTypeName : "CHAR(36)" , createFormat : "CHAR(36)" ) ) ;
118
118
119
119
// null
120
- var typeNull = AddDbTypeMapping ( new ( typeof ( object ) , [ DbType . Object ] ) ) ;
120
+ var typeNull = AddDbTypeMapping ( new ( typeof ( object ) , [ DbType . Object ] ) ) ;
121
121
AddColumnTypeMetadata ( new ( "NULL" , typeNull , MySqlDbType . Null ) ) ;
122
122
}
123
123
0 commit comments