@@ -26,8 +26,8 @@ public DefaultTypeMap(Type type)
2626 Properties = GetSettableProps ( type ) ;
2727 _type = type ;
2828 }
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 )
3131 {
3232 if ( ReferenceEquals ( x , y ) ) return true ;
3333 if ( x == null || y == null ) return false ;
@@ -40,7 +40,7 @@ static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y)
4040 internal static MethodInfo GetPropertySetter ( PropertyInfo propertyInfo , Type type )
4141 {
4242 if ( propertyInfo . DeclaringType == type ) return propertyInfo . GetSetMethod ( true ) ;
43- #if NETSTANDARD2_0
43+ #if NETSTANDARD1_3
4444 return propertyInfo . DeclaringType . GetProperties ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance )
4545 . Single ( x => x . Name == propertyInfo . Name
4646 && x . PropertyType == propertyInfo . PropertyType
@@ -91,15 +91,15 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
9191 int i = 0 ;
9292 for ( ; i < ctorParameters . Length ; i ++ )
9393 {
94- if ( ! String . Equals ( ctorParameters [ i ] . Name , names [ i ] , StringComparison . OrdinalIgnoreCase ) )
94+ if ( ! string . Equals ( ctorParameters [ i ] . Name , names [ i ] , StringComparison . OrdinalIgnoreCase ) )
9595 break ;
9696 if ( types [ i ] == typeof ( byte [ ] ) && ctorParameters [ i ] . ParameterType . FullName == SqlMapper . LinqBinary )
9797 continue ;
9898 var unboxedType = Nullable . GetUnderlyingType ( ctorParameters [ i ] . ParameterType ) ?? ctorParameters [ i ] . ParameterType ;
9999 if ( ( unboxedType != types [ i ] && ! SqlMapper . HasTypeHandler ( unboxedType ) )
100- && ! ( unboxedType . IsEnum && Enum . GetUnderlyingType ( unboxedType ) == types [ i ] )
100+ && ! ( unboxedType . IsEnum ( ) && Enum . GetUnderlyingType ( unboxedType ) == types [ i ] )
101101 && ! ( unboxedType == typeof ( char ) && types [ i ] == typeof ( string ) )
102- && ! ( unboxedType . IsEnum && types [ i ] == typeof ( string ) ) )
102+ && ! ( unboxedType . IsEnum ( ) && types [ i ] == typeof ( string ) ) )
103103 {
104104 break ;
105105 }
@@ -118,7 +118,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
118118 public ConstructorInfo FindExplicitConstructor ( )
119119 {
120120 var constructors = _type . GetConstructors ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
121- #if NETSTANDARD2_0
121+ #if NETSTANDARD1_3
122122 var withAttr = constructors . Where ( c => c . CustomAttributes . Any ( x => x . AttributeType == typeof ( ExplicitConstructorAttribute ) ) ) . ToList ( ) ;
123123#else
124124 var withAttr = constructors . Where ( c => c . GetCustomAttributes ( typeof ( ExplicitConstructorAttribute ) , true ) . Length > 0 ) . ToList ( ) ;
@@ -152,13 +152,13 @@ public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor,
152152 /// <returns>Mapping implementation</returns>
153153 public SqlMapper . IMemberMap GetMember ( string columnName )
154154 {
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 ) ) ;
157157
158158 if ( property == null && MatchNamesWithUnderscores )
159159 {
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 ) ) ;
162162 }
163163
164164 if ( property != null )
@@ -169,20 +169,20 @@ public SqlMapper.IMemberMap GetMember(string columnName)
169169
170170 // preference order is:
171171 // 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 ) ) ;
176176
177177 if ( field == null && MatchNamesWithUnderscores )
178178 {
179179 var effectiveColumnName = columnName . Replace ( "_" , "" ) ;
180- backingFieldName = "<" + effectiveColumnName + ">k__BackingField" ;
180+ backingFieldName = "<" + effectiveColumnName + ">k__BackingField" ;
181181
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 ) ) ;
186186 }
187187
188188 if ( field != null )
0 commit comments