Skip to content

Commit 9d3ab17

Browse files
authored
Merge pull request #107 from AutoMapper/ImprovingAnonymousTypeExpressionMapping
Add FindPathMapByDestinationPath to local helper.
2 parents 855cbb7 + 8a81a1c commit 9d3ab17

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/AutoMapper.Extensions.ExpressionMapping/TypeMapHelper.cs

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public static string GetDestinationName(this IMemberMap memberMap)
3939
throw new ArgumentException(nameof(memberMap));
4040
}
4141

42+
public static PathMap FindPathMapByDestinationFullPath(this TypeMap typeMap, string destinationFullPath) =>
43+
typeMap.PathMaps.SingleOrDefault(item => string.Join(".", item.MemberPath.Members.Select(m => m.Name)) == destinationFullPath);
44+
4245
private static Exception PropertyConfigurationException(TypeMap typeMap, params string[] unmappedPropertyNames)
4346
=> new AutoMapperConfigurationException(new[] { new AutoMapperConfigurationException.TypeMapConfigErrors(typeMap, unmappedPropertyNames, true) });
4447

src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ TypeMap GetTypeMap() => BothTypesAreAnonymous()
679679

680680
var typeMap = GetTypeMap();
681681

682-
PathMap pathMap = typeMap.FindPathMapByDestinationPath(destinationFullPath: sourceFullName);
682+
PathMap pathMap = typeMap.FindPathMapByDestinationFullPath(destinationFullPath: sourceFullName);
683683
if (pathMap != null)
684684
{
685685
propertyMapInfoList.Add(new PropertyMapInfo(pathMap.CustomMapExpression, new List<MemberInfo>()));

0 commit comments

Comments
 (0)