示例#1
0
        private static MemberAssignment BindMappedTypeExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary <ExpressionRequest, int> typePairCount, LetPropertyMaps letPropertyMaps)
        {
            var transformedExpression = configuration.ExpressionBuilder.CreateMapExpression(request, result.ResolutionExpression, typePairCount, letPropertyMaps);

            if (transformedExpression == null)
            {
                return(null);
            }
            // Handles null source property so it will not create an object with possible non-nullable properties which would result in an exception.
            if (propertyMap.AllowsNullDestinationValues() && !(result.ResolutionExpression is ParameterExpression) && !result.ResolutionExpression.Type.IsCollectionType())
            {
                transformedExpression = result.ResolutionExpression.IfNullElse(Constant(null, transformedExpression.Type), transformedExpression);
            }

            return(Bind(propertyMap.DestinationMember, transformedExpression));
        }