Example #1
0
        private static ExpressionResolutionResult ResolveExpression(PropertyMap propertyMap, Type currentType,
                                                                    Expression instanceParameter, LetPropertyMaps letPropertyMaps)
        {
            var result = new ExpressionResolutionResult(instanceParameter, currentType);

            var matchingExpressionConverter =
                ExpressionResultConverters.FirstOrDefault(c => c.CanGetExpressionResolutionResult(result, propertyMap));

            result = matchingExpressionConverter?.GetExpressionResolutionResult(result, propertyMap, letPropertyMaps)
                     ?? throw new Exception("Can't resolve this to Queryable Expression");

            if (propertyMap.NullSubstitute != null && result.Type.IsNullableType())
            {
                var currentChild     = result.ResolutionExpression;
                var currentChildType = result.Type;
                var nullSubstitute   = propertyMap.NullSubstitute;

                var newParameter = result.ResolutionExpression;
                var converter    = new NullSubstitutionConversionVisitor(newParameter, nullSubstitute);

                currentChild     = converter.Visit(currentChild);
                currentChildType = currentChildType.GetTypeOfNullable();

                return(new ExpressionResolutionResult(currentChild, currentChildType));
            }

            return(result);
        }
Example #2
0
        private ExpressionResolutionResult ResolveExpression(IMemberMap propertyMap, Type currentType, Expression instanceParameter, LetPropertyMaps letPropertyMaps)
        {
            var result = new ExpressionResolutionResult(instanceParameter, currentType);
            var matchingExpressionConverter = _configurationProvider.ResultConverters.FirstOrDefault(c => c.CanGetExpressionResolutionResult(result, propertyMap));

            if (matchingExpressionConverter == null)
            {
                ThrowCannotMap(propertyMap, result);
                return(null);
            }
            result = matchingExpressionConverter.GetExpressionResolutionResult(result, propertyMap, letPropertyMaps);
            if (propertyMap.NullSubstitute != null && result.Type.IsNullableType())
            {
                var currentChild     = result.ResolutionExpression;
                var currentChildType = result.Type;
                var nullSubstitute   = propertyMap.NullSubstitute;

                var newParameter = result.ResolutionExpression;
                var converter    = new NullSubstitutionConversionVisitor(newParameter, nullSubstitute);

                currentChild     = converter.Visit(currentChild);
                currentChildType = currentChildType.GetTypeOfNullable();

                return(new ExpressionResolutionResult(currentChild, currentChildType));
            }

            return(result);
        }
        public ExpressionResolutionResult GetExpressionResolutionResult(ExpressionResolutionResult expressionResolutionResult, PropertyMap propertyMap, IValueResolver valueResolver)
        {
            Expression currentChild     = expressionResolutionResult.ResolutionExpression;
            Type       currentChildType = expressionResolutionResult.Type;
            var        nullSubstitute   = propertyMap.NullSubstitute;

            var newParameter = expressionResolutionResult.ResolutionExpression;
            var converter    = new NullSubstitutionConversionVisitor(newParameter, nullSubstitute);

            currentChild     = converter.Visit(currentChild);
            currentChildType = currentChildType.GetTypeOfNullable();

            return(new ExpressionResolutionResult(currentChild, currentChildType));
        }
        public ExpressionResolutionResult GetExpressionResolutionResult(ExpressionResolutionResult expressionResolutionResult, PropertyMap propertyMap, IValueResolver valueResolver)
        {
            Expression currentChild = expressionResolutionResult.ResolutionExpression;
            Type currentChildType = expressionResolutionResult.Type;
            var nullSubstitute = propertyMap.NullSubstitute;

            var newParameter = expressionResolutionResult.ResolutionExpression;
            var converter = new NullSubstitutionConversionVisitor(newParameter, nullSubstitute);

            currentChild = converter.Visit(currentChild);
            currentChildType = currentChildType.GetTypeOfNullable();

            return new ExpressionResolutionResult(currentChild, currentChildType);
        }