@@ -175,9 +175,9 @@ private void MapIdPropertyFor<TDocument>(Expression<Func<TDocument, object>> obj
175
175
var memberInfo = new MemberInfoResolver ( objectPath ) ;
176
176
var fieldName = memberInfo . Members . Single ( ) . Name ;
177
177
178
- if ( _idProperties . ContainsKey ( typeof ( TDocument ) ) )
178
+ if ( _idProperties . TryGetValue ( typeof ( TDocument ) , out var idPropertyFieldName ) )
179
179
{
180
- if ( _idProperties [ typeof ( TDocument ) ] . Equals ( fieldName ) ) return ;
180
+ if ( idPropertyFieldName . Equals ( fieldName ) ) return ;
181
181
182
182
throw new ArgumentException (
183
183
$ "Cannot map '{ fieldName } ' as the id property for type '{ typeof ( TDocument ) . Name } ': it already has '{ _idProperties [ typeof ( TDocument ) ] } ' mapped.") ;
@@ -193,9 +193,9 @@ private void MapRoutePropertyFor<TDocument>(Expression<Func<TDocument, object>>
193
193
var memberInfo = new MemberInfoResolver ( objectPath ) ;
194
194
var fieldName = memberInfo . Members . Single ( ) . Name ;
195
195
196
- if ( _routeProperties . ContainsKey ( typeof ( TDocument ) ) )
196
+ if ( _routeProperties . TryGetValue ( typeof ( TDocument ) , out var routePropertyFieldName ) )
197
197
{
198
- if ( _routeProperties [ typeof ( TDocument ) ] . Equals ( fieldName ) ) return ;
198
+ if ( routePropertyFieldName . Equals ( fieldName ) ) return ;
199
199
200
200
throw new ArgumentException (
201
201
$ "Cannot map '{ fieldName } ' as the route property for type '{ typeof ( TDocument ) . Name } ': it already has '{ _routeProperties [ typeof ( TDocument ) ] } ' mapped.") ;
@@ -227,10 +227,10 @@ private void ApplyPropertyMappings<TDocument>(IList<IClrPropertyMapping<TDocumen
227
227
memberInfo = typeof ( TDocument ) . GetMember ( memberInfo . Name , bindingFlags ) . First ( ) ;
228
228
}
229
229
230
- if ( _propertyMappings . ContainsKey ( memberInfo ) )
230
+ if ( _propertyMappings . TryGetValue ( memberInfo , out var propertyMapping ) )
231
231
{
232
232
var newName = mapping . NewName ;
233
- var mappedAs = _propertyMappings [ memberInfo ] . Name ;
233
+ var mappedAs = propertyMapping . Name ;
234
234
var typeName = typeof ( TDocument ) . Name ;
235
235
if ( mappedAs . IsNullOrEmpty ( ) && newName . IsNullOrEmpty ( ) )
236
236
throw new ArgumentException ( $ "Property mapping '{ e } ' on type is already ignored") ;
0 commit comments