@@ -26,8 +26,8 @@ public DefaultTypeMap(Type type)
26
26
Properties = GetSettableProps ( type ) ;
27
27
_type = type ;
28
28
}
29
- #if NETSTANDARD2_0
30
- static bool IsParameterMatch ( ParameterInfo [ ] x , ParameterInfo [ ] y )
29
+ #if NETSTANDARD1_3
30
+ private static bool IsParameterMatch ( ParameterInfo [ ] x , ParameterInfo [ ] y )
31
31
{
32
32
if ( ReferenceEquals ( x , y ) ) return true ;
33
33
if ( x == null || y == null ) return false ;
@@ -40,7 +40,7 @@ static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y)
40
40
internal static MethodInfo GetPropertySetter ( PropertyInfo propertyInfo , Type type )
41
41
{
42
42
if ( propertyInfo . DeclaringType == type ) return propertyInfo . GetSetMethod ( true ) ;
43
- #if NETSTANDARD2_0
43
+ #if NETSTANDARD1_3
44
44
return propertyInfo . DeclaringType . GetProperties ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance )
45
45
. Single ( x => x . Name == propertyInfo . Name
46
46
&& x . PropertyType == propertyInfo . PropertyType
@@ -91,15 +91,15 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
91
91
int i = 0 ;
92
92
for ( ; i < ctorParameters . Length ; i ++ )
93
93
{
94
- if ( ! String . Equals ( ctorParameters [ i ] . Name , names [ i ] , StringComparison . OrdinalIgnoreCase ) )
94
+ if ( ! string . Equals ( ctorParameters [ i ] . Name , names [ i ] , StringComparison . OrdinalIgnoreCase ) )
95
95
break ;
96
96
if ( types [ i ] == typeof ( byte [ ] ) && ctorParameters [ i ] . ParameterType . FullName == SqlMapper . LinqBinary )
97
97
continue ;
98
98
var unboxedType = Nullable . GetUnderlyingType ( ctorParameters [ i ] . ParameterType ) ?? ctorParameters [ i ] . ParameterType ;
99
99
if ( ( unboxedType != types [ i ] && ! SqlMapper . HasTypeHandler ( unboxedType ) )
100
- && ! ( unboxedType . IsEnum && Enum . GetUnderlyingType ( unboxedType ) == types [ i ] )
100
+ && ! ( unboxedType . IsEnum ( ) && Enum . GetUnderlyingType ( unboxedType ) == types [ i ] )
101
101
&& ! ( unboxedType == typeof ( char ) && types [ i ] == typeof ( string ) )
102
- && ! ( unboxedType . IsEnum && types [ i ] == typeof ( string ) ) )
102
+ && ! ( unboxedType . IsEnum ( ) && types [ i ] == typeof ( string ) ) )
103
103
{
104
104
break ;
105
105
}
@@ -118,7 +118,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
118
118
public ConstructorInfo FindExplicitConstructor ( )
119
119
{
120
120
var constructors = _type . GetConstructors ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
121
- #if NETSTANDARD2_0
121
+ #if NETSTANDARD1_3
122
122
var withAttr = constructors . Where ( c => c . CustomAttributes . Any ( x => x . AttributeType == typeof ( ExplicitConstructorAttribute ) ) ) . ToList ( ) ;
123
123
#else
124
124
var withAttr = constructors . Where ( c => c . GetCustomAttributes ( typeof ( ExplicitConstructorAttribute ) , true ) . Length > 0 ) . ToList ( ) ;
@@ -152,13 +152,13 @@ public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor,
152
152
/// <returns>Mapping implementation</returns>
153
153
public SqlMapper . IMemberMap GetMember ( string columnName )
154
154
{
155
- var property = Properties . FirstOrDefault ( p => string . Equals ( p . Name , columnName , StringComparison . Ordinal ) )
156
- ?? Properties . FirstOrDefault ( p => string . Equals ( p . Name , columnName , StringComparison . OrdinalIgnoreCase ) ) ;
155
+ var property = Properties . Find ( p => string . Equals ( p . Name , columnName , StringComparison . Ordinal ) )
156
+ ?? Properties . Find ( p => string . Equals ( p . Name , columnName , StringComparison . OrdinalIgnoreCase ) ) ;
157
157
158
158
if ( property == null && MatchNamesWithUnderscores )
159
159
{
160
- property = Properties . FirstOrDefault ( p => string . Equals ( p . Name , columnName . Replace ( "_" , "" ) , StringComparison . Ordinal ) )
161
- ?? Properties . FirstOrDefault ( p => string . Equals ( p . Name , columnName . Replace ( "_" , "" ) , StringComparison . OrdinalIgnoreCase ) ) ;
160
+ property = Properties . Find ( p => string . Equals ( p . Name , columnName . Replace ( "_" , "" ) , StringComparison . Ordinal ) )
161
+ ?? Properties . Find ( p => string . Equals ( p . Name , columnName . Replace ( "_" , "" ) , StringComparison . OrdinalIgnoreCase ) ) ;
162
162
}
163
163
164
164
if ( property != null )
@@ -169,20 +169,20 @@ public SqlMapper.IMemberMap GetMember(string columnName)
169
169
170
170
// preference order is:
171
171
// exact match over underscre match, exact case over wrong case, backing fields over regular fields, match-inc-underscores over match-exc-underscores
172
- var field = _fields . FirstOrDefault ( p => string . Equals ( p . Name , columnName , StringComparison . Ordinal ) )
173
- ?? _fields . FirstOrDefault ( p => string . Equals ( p . Name , backingFieldName , StringComparison . Ordinal ) )
174
- ?? _fields . FirstOrDefault ( p => string . Equals ( p . Name , columnName , StringComparison . OrdinalIgnoreCase ) )
175
- ?? _fields . FirstOrDefault ( p => string . Equals ( p . Name , backingFieldName , StringComparison . OrdinalIgnoreCase ) ) ;
172
+ var field = _fields . Find ( p => string . Equals ( p . Name , columnName , StringComparison . Ordinal ) )
173
+ ?? _fields . Find ( p => string . Equals ( p . Name , backingFieldName , StringComparison . Ordinal ) )
174
+ ?? _fields . Find ( p => string . Equals ( p . Name , columnName , StringComparison . OrdinalIgnoreCase ) )
175
+ ?? _fields . Find ( p => string . Equals ( p . Name , backingFieldName , StringComparison . OrdinalIgnoreCase ) ) ;
176
176
177
177
if ( field == null && MatchNamesWithUnderscores )
178
178
{
179
179
var effectiveColumnName = columnName . Replace ( "_" , "" ) ;
180
- backingFieldName = "<" + effectiveColumnName + ">k__BackingField" ;
180
+ backingFieldName = "<" + effectiveColumnName + ">k__BackingField" ;
181
181
182
- field = _fields . FirstOrDefault ( p => string . Equals ( p . Name , effectiveColumnName , StringComparison . Ordinal ) )
183
- ?? _fields . FirstOrDefault ( p => string . Equals ( p . Name , backingFieldName , StringComparison . Ordinal ) )
184
- ?? _fields . FirstOrDefault ( p => string . Equals ( p . Name , effectiveColumnName , StringComparison . OrdinalIgnoreCase ) )
185
- ?? _fields . FirstOrDefault ( p => string . Equals ( p . Name , backingFieldName , StringComparison . OrdinalIgnoreCase ) ) ;
182
+ field = _fields . Find ( p => string . Equals ( p . Name , effectiveColumnName , StringComparison . Ordinal ) )
183
+ ?? _fields . Find ( p => string . Equals ( p . Name , backingFieldName , StringComparison . Ordinal ) )
184
+ ?? _fields . Find ( p => string . Equals ( p . Name , effectiveColumnName , StringComparison . OrdinalIgnoreCase ) )
185
+ ?? _fields . Find ( p => string . Equals ( p . Name , backingFieldName , StringComparison . OrdinalIgnoreCase ) ) ;
186
186
}
187
187
188
188
if ( field != null )
0 commit comments