@@ -20,18 +20,18 @@ private TypeMapper()
2020 m_mySqlDbTypeToColumnTypeMetadata = [ ] ;
2121
2222 // 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 ) ) ) ;
2424 AddColumnTypeMetadata ( new ( "TINYINT" , typeBoolean , MySqlDbType . Bool , isUnsigned : false , length : 1 , columnSize : 1 , simpleDataTypeName : "BOOL" , createFormat : "BOOL" ) ) ;
2525
2626 // 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 ) ) ) ;
3535 AddColumnTypeMetadata ( new ( "TINYINT" , typeSbyte , MySqlDbType . Byte , isUnsigned : false ) ) ;
3636 AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true , length : 1 ) ) ;
3737 AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true ) ) ;
@@ -46,18 +46,18 @@ private TypeMapper()
4646 AddColumnTypeMetadata ( new ( "BIT" , typeUlong , MySqlDbType . Bit ) ) ;
4747
4848 // 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 ) ) ) ;
5252 AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . NewDecimal , createFormat : "DECIMAL({0},{1});precision,scale" ) ) ;
5353 AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . NewDecimal , isUnsigned : true , createFormat : "DECIMAL({0},{1}) UNSIGNED;precision,scale" ) ) ;
5454 AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . Decimal ) ) ;
5555 AddColumnTypeMetadata ( new ( "DOUBLE" , typeDouble , MySqlDbType . Double ) ) ;
5656 AddColumnTypeMetadata ( new ( "FLOAT" , typeFloat , MySqlDbType . Float ) ) ;
5757
5858 // 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 ! ) ) ;
6161 AddColumnTypeMetadata ( new ( "VARCHAR" , typeString , MySqlDbType . VarChar , createFormat : "VARCHAR({0});size" ) ) ;
6262 AddColumnTypeMetadata ( new ( "VARCHAR" , typeString , MySqlDbType . VarString ) ) ;
6363 AddColumnTypeMetadata ( new ( "CHAR" , typeFixedString , MySqlDbType . String , createFormat : "CHAR({0});size" ) ) ;
@@ -70,7 +70,7 @@ private TypeMapper()
7070 AddColumnTypeMetadata ( new ( "JSON" , typeString , MySqlDbType . JSON ) ) ;
7171
7272 // binary
73- var typeBinary = AddDbTypeMapping ( new ( typeof ( byte [ ] ) , [ DbType . Binary ] ) ) ;
73+ var typeBinary = AddDbTypeMapping ( new ( typeof ( byte [ ] ) , [ DbType . Binary ] ) ) ;
7474 AddColumnTypeMetadata ( new ( "BLOB" , typeBinary , MySqlDbType . Blob , binary : true , columnSize : ushort . MaxValue , simpleDataTypeName : "BLOB" ) ) ;
7575 AddColumnTypeMetadata ( new ( "BINARY" , typeBinary , MySqlDbType . Binary , binary : true , simpleDataTypeName : "BLOB" , createFormat : "BINARY({0});length" ) ) ;
7676 AddColumnTypeMetadata ( new ( "VARBINARY" , typeBinary , MySqlDbType . VarBinary , binary : true , simpleDataTypeName : "BLOB" , createFormat : "VARBINARY({0});length" ) ) ;
@@ -91,15 +91,15 @@ private TypeMapper()
9191
9292 // date/time
9393#if NET6_0_OR_GREATER
94- AddDbTypeMapping ( new ( typeof ( DateOnly ) , [ DbType . Date ] ) ) ;
94+ AddDbTypeMapping ( new ( typeof ( DateOnly ) , [ DbType . Date ] ) ) ;
9595#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 ] ) ) ;
9999#if NET6_0_OR_GREATER
100- AddDbTypeMapping ( new ( typeof ( TimeOnly ) , [ DbType . Time ] ) ) ;
100+ AddDbTypeMapping ( new ( typeof ( TimeOnly ) , [ DbType . Time ] ) ) ;
101101#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 ) ) ) ;
103103 AddColumnTypeMetadata ( new ( "DATETIME" , typeDateTime , MySqlDbType . DateTime ) ) ;
104104 AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Date ) ) ;
105105 AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Newdate ) ) ;
@@ -113,11 +113,11 @@ private TypeMapper()
113113#else
114114 Func < object , object > convertGuid = static o => Guid . Parse ( Convert . ToString ( o , CultureInfo . InvariantCulture ) ! ) ;
115115#endif
116- var typeGuid = AddDbTypeMapping ( new ( typeof ( Guid ) , [ DbType . Guid ] , convert : convertGuid ) ) ;
116+ var typeGuid = AddDbTypeMapping ( new ( typeof ( Guid ) , [ DbType . Guid ] , convert : convertGuid ) ) ;
117117 AddColumnTypeMetadata ( new ( "CHAR" , typeGuid , MySqlDbType . Guid , length : 36 , simpleDataTypeName : "CHAR(36)" , createFormat : "CHAR(36)" ) ) ;
118118
119119 // null
120- var typeNull = AddDbTypeMapping ( new ( typeof ( object ) , [ DbType . Object ] ) ) ;
120+ var typeNull = AddDbTypeMapping ( new ( typeof ( object ) , [ DbType . Object ] ) ) ;
121121 AddColumnTypeMetadata ( new ( "NULL" , typeNull , MySqlDbType . Null ) ) ;
122122 }
123123
0 commit comments