@@ -23,18 +23,18 @@ private TypeMapper()
2323 m_mySqlDbTypeToColumnTypeMetadata = new ( ) ;
2424
2525 // boolean
26- var typeBoolean = AddDbTypeMapping ( new ( typeof ( bool ) , new [ ] { DbType . Boolean } , convert : o => Convert . ToBoolean ( o ) ) ) ;
26+ var typeBoolean = AddDbTypeMapping ( new ( typeof ( bool ) , new [ ] { DbType . Boolean } , convert : static o => Convert . ToBoolean ( o ) ) ) ;
2727 AddColumnTypeMetadata ( new ( "TINYINT" , typeBoolean , MySqlDbType . Bool , isUnsigned : false , length : 1 , columnSize : 1 , simpleDataTypeName : "BOOL" , createFormat : "BOOL" ) ) ;
2828
2929 // integers
30- var typeSbyte = AddDbTypeMapping ( new ( typeof ( sbyte ) , new [ ] { DbType . SByte } , convert : o => Convert . ToSByte ( o ) ) ) ;
31- var typeByte = AddDbTypeMapping ( new ( typeof ( byte ) , new [ ] { DbType . Byte } , convert : o => Convert . ToByte ( o ) ) ) ;
32- var typeShort = AddDbTypeMapping ( new ( typeof ( short ) , new [ ] { DbType . Int16 } , convert : o => Convert . ToInt16 ( o ) ) ) ;
33- var typeUshort = AddDbTypeMapping ( new ( typeof ( ushort ) , new [ ] { DbType . UInt16 } , convert : o => Convert . ToUInt16 ( o ) ) ) ;
34- var typeInt = AddDbTypeMapping ( new ( typeof ( int ) , new [ ] { DbType . Int32 } , convert : o => Convert . ToInt32 ( o ) ) ) ;
35- var typeUint = AddDbTypeMapping ( new ( typeof ( uint ) , new [ ] { DbType . UInt32 } , convert : o => Convert . ToUInt32 ( o ) ) ) ;
36- var typeLong = AddDbTypeMapping ( new ( typeof ( long ) , new [ ] { DbType . Int64 } , convert : o => Convert . ToInt64 ( o ) ) ) ;
37- var typeUlong = AddDbTypeMapping ( new ( typeof ( ulong ) , new [ ] { DbType . UInt64 } , convert : o => Convert . ToUInt64 ( o ) ) ) ;
30+ var typeSbyte = AddDbTypeMapping ( new ( typeof ( sbyte ) , new [ ] { DbType . SByte } , convert : static o => Convert . ToSByte ( o ) ) ) ;
31+ var typeByte = AddDbTypeMapping ( new ( typeof ( byte ) , new [ ] { DbType . Byte } , convert : static o => Convert . ToByte ( o ) ) ) ;
32+ var typeShort = AddDbTypeMapping ( new ( typeof ( short ) , new [ ] { DbType . Int16 } , convert : static o => Convert . ToInt16 ( o ) ) ) ;
33+ var typeUshort = AddDbTypeMapping ( new ( typeof ( ushort ) , new [ ] { DbType . UInt16 } , convert : static o => Convert . ToUInt16 ( o ) ) ) ;
34+ var typeInt = AddDbTypeMapping ( new ( typeof ( int ) , new [ ] { DbType . Int32 } , convert : static o => Convert . ToInt32 ( o ) ) ) ;
35+ var typeUint = AddDbTypeMapping ( new ( typeof ( uint ) , new [ ] { DbType . UInt32 } , convert : static o => Convert . ToUInt32 ( o ) ) ) ;
36+ var typeLong = AddDbTypeMapping ( new ( typeof ( long ) , new [ ] { DbType . Int64 } , convert : static o => Convert . ToInt64 ( o ) ) ) ;
37+ var typeUlong = AddDbTypeMapping ( new ( typeof ( ulong ) , new [ ] { DbType . UInt64 } , convert : static o => Convert . ToUInt64 ( o ) ) ) ;
3838 AddColumnTypeMetadata ( new ( "TINYINT" , typeSbyte , MySqlDbType . Byte , isUnsigned : false ) ) ;
3939 AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true , length : 1 ) ) ;
4040 AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true ) ) ;
@@ -49,9 +49,9 @@ private TypeMapper()
4949 AddColumnTypeMetadata ( new ( "BIT" , typeUlong , MySqlDbType . Bit ) ) ;
5050
5151 // decimals
52- var typeDecimal = AddDbTypeMapping ( new ( typeof ( decimal ) , new [ ] { DbType . Decimal , DbType . Currency , DbType . VarNumeric } , convert : o => Convert . ToDecimal ( o ) ) ) ;
53- var typeDouble = AddDbTypeMapping ( new ( typeof ( double ) , new [ ] { DbType . Double } , convert : o => Convert . ToDouble ( o ) ) ) ;
54- var typeFloat = AddDbTypeMapping ( new ( typeof ( float ) , new [ ] { DbType . Single } , convert : o => Convert . ToSingle ( o ) ) ) ;
52+ var typeDecimal = AddDbTypeMapping ( new ( typeof ( decimal ) , new [ ] { DbType . Decimal , DbType . Currency , DbType . VarNumeric } , convert : static o => Convert . ToDecimal ( o ) ) ) ;
53+ var typeDouble = AddDbTypeMapping ( new ( typeof ( double ) , new [ ] { DbType . Double } , convert : static o => Convert . ToDouble ( o ) ) ) ;
54+ var typeFloat = AddDbTypeMapping ( new ( typeof ( float ) , new [ ] { DbType . Single } , convert : static o => Convert . ToSingle ( o ) ) ) ;
5555 AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . NewDecimal , createFormat : "DECIMAL({0},{1});precision,scale" ) ) ;
5656 AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . Decimal ) ) ;
5757 AddColumnTypeMetadata ( new ( "DOUBLE" , typeDouble , MySqlDbType . Double ) ) ;
@@ -95,7 +95,7 @@ private TypeMapper()
9595 var typeDate = AddDbTypeMapping ( new ( typeof ( DateTime ) , new [ ] { DbType . Date } ) ) ;
9696 var typeDateTime = AddDbTypeMapping ( new ( typeof ( DateTime ) , new [ ] { DbType . DateTime , DbType . DateTime2 , DbType . DateTimeOffset } ) ) ;
9797 AddDbTypeMapping ( new ( typeof ( DateTimeOffset ) , new [ ] { DbType . DateTimeOffset } ) ) ;
98- var typeTime = AddDbTypeMapping ( new ( typeof ( TimeSpan ) , new [ ] { DbType . Time } , convert : o => o is string s ? Utility . ParseTimeSpan ( Encoding . UTF8 . GetBytes ( s ) ) : Convert . ChangeType ( o , typeof ( TimeSpan ) ) ) ) ;
98+ var typeTime = AddDbTypeMapping ( new ( typeof ( TimeSpan ) , new [ ] { DbType . Time } , convert : static o => o is string s ? Utility . ParseTimeSpan ( Encoding . UTF8 . GetBytes ( s ) ) : Convert . ChangeType ( o , typeof ( TimeSpan ) ) ) ) ;
9999 AddColumnTypeMetadata ( new ( "DATETIME" , typeDateTime , MySqlDbType . DateTime ) ) ;
100100 AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Date ) ) ;
101101 AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Newdate ) ) ;
@@ -104,7 +104,7 @@ private TypeMapper()
104104 AddColumnTypeMetadata ( new ( "YEAR" , typeInt , MySqlDbType . Year ) ) ;
105105
106106 // guid
107- var typeGuid = AddDbTypeMapping ( new ( typeof ( Guid ) , new [ ] { DbType . Guid } , convert : o => Guid . Parse ( Convert . ToString ( o ) ! ) ) ) ;
107+ var typeGuid = AddDbTypeMapping ( new ( typeof ( Guid ) , new [ ] { DbType . Guid } , convert : static o => Guid . Parse ( Convert . ToString ( o ) ! ) ) ) ;
108108 AddColumnTypeMetadata ( new ( "CHAR" , typeGuid , MySqlDbType . Guid , length : 36 , simpleDataTypeName : "CHAR(36)" , createFormat : "CHAR(36)" ) ) ;
109109
110110 // null
0 commit comments