@@ -273,7 +273,7 @@ private MemberInitExpression GetAnonymousTypeMemberInitExpression(Dictionary<str
273
273
(
274
274
Expression . New ( newAnonymousType ) ,
275
275
bindingExpressions
276
- . ToDictionary ( be => be . Key , be => newAnonymousType . GetMember ( be . Key ) [ 0 ] )
276
+ . ToDictionary ( be => be . Key , be => newAnonymousType . GetProperty ( be . Key ) )
277
277
. Select ( member => Expression . Bind ( member . Value , bindingExpressions [ member . Key ] ) )
278
278
) ;
279
279
}
@@ -620,6 +620,12 @@ protected void FindDestinationFullName(Type typeSource, Type typeDestination, st
620
620
bool BothTypesAreAnonymous ( )
621
621
=> IsAnonymousType ( typeSource ) && IsAnonymousType ( typeDestination ) ;
622
622
623
+ TypeMap GetTypeMap ( ) => BothTypesAreAnonymous ( )
624
+ ? anonymousTypesConfigurationProvider . CheckIfTypeMapExists ( sourceType : typeDestination , destinationType : typeSource )
625
+ : ConfigurationProvider . CheckIfTypeMapExists ( sourceType : typeDestination , destinationType : typeSource ) ;
626
+ //The destination becomes the source because to map a source expression to a destination expression,
627
+ //we need the expressions used to create the source from the destination
628
+
623
629
if ( typeSource == typeDestination )
624
630
{
625
631
var sourceFullNameArray = sourceFullName . Split ( new [ ] { period [ 0 ] } , StringSplitOptions . RemoveEmptyEntries ) ;
@@ -671,11 +677,7 @@ bool BothTypesAreAnonymous()
671
677
}
672
678
}
673
679
674
- var typeMap = BothTypesAreAnonymous ( )
675
- ? anonymousTypesConfigurationProvider . CheckIfTypeMapExists ( sourceType : typeDestination , destinationType : typeSource )
676
- : ConfigurationProvider . CheckIfTypeMapExists ( sourceType : typeDestination , destinationType : typeSource ) ;
677
- //The destination becomes the source because to map a source expression to a destination expression,
678
- //we need the expressions used to create the source from the destination
680
+ var typeMap = GetTypeMap ( ) ;
679
681
680
682
PathMap pathMap = typeMap . FindPathMapByDestinationPath ( destinationFullPath : sourceFullName ) ;
681
683
if ( pathMap != null )
0 commit comments