@@ -23,18 +23,18 @@ private TypeMapper()
23
23
m_mySqlDbTypeToColumnTypeMetadata = new ( ) ;
24
24
25
25
// 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 ) ) ) ;
27
27
AddColumnTypeMetadata ( new ( "TINYINT" , typeBoolean , MySqlDbType . Bool , isUnsigned : false , length : 1 , columnSize : 1 , simpleDataTypeName : "BOOL" , createFormat : "BOOL" ) ) ;
28
28
29
29
// 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 ) ) ) ;
38
38
AddColumnTypeMetadata ( new ( "TINYINT" , typeSbyte , MySqlDbType . Byte , isUnsigned : false ) ) ;
39
39
AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true , length : 1 ) ) ;
40
40
AddColumnTypeMetadata ( new ( "TINYINT" , typeByte , MySqlDbType . UByte , isUnsigned : true ) ) ;
@@ -49,9 +49,9 @@ private TypeMapper()
49
49
AddColumnTypeMetadata ( new ( "BIT" , typeUlong , MySqlDbType . Bit ) ) ;
50
50
51
51
// 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 ) ) ) ;
55
55
AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . NewDecimal , createFormat : "DECIMAL({0},{1});precision,scale" ) ) ;
56
56
AddColumnTypeMetadata ( new ( "DECIMAL" , typeDecimal , MySqlDbType . Decimal ) ) ;
57
57
AddColumnTypeMetadata ( new ( "DOUBLE" , typeDouble , MySqlDbType . Double ) ) ;
@@ -95,7 +95,7 @@ private TypeMapper()
95
95
var typeDate = AddDbTypeMapping ( new ( typeof ( DateTime ) , new [ ] { DbType . Date } ) ) ;
96
96
var typeDateTime = AddDbTypeMapping ( new ( typeof ( DateTime ) , new [ ] { DbType . DateTime , DbType . DateTime2 , DbType . DateTimeOffset } ) ) ;
97
97
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 ) ) ) ) ;
99
99
AddColumnTypeMetadata ( new ( "DATETIME" , typeDateTime , MySqlDbType . DateTime ) ) ;
100
100
AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Date ) ) ;
101
101
AddColumnTypeMetadata ( new ( "DATE" , typeDate , MySqlDbType . Newdate ) ) ;
@@ -104,7 +104,7 @@ private TypeMapper()
104
104
AddColumnTypeMetadata ( new ( "YEAR" , typeInt , MySqlDbType . Year ) ) ;
105
105
106
106
// 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 ) ! ) ) ) ;
108
108
AddColumnTypeMetadata ( new ( "CHAR" , typeGuid , MySqlDbType . Guid , length : 36 , simpleDataTypeName : "CHAR(36)" , createFormat : "CHAR(36)" ) ) ;
109
109
110
110
// null
0 commit comments