public virtual SqlExpression Translate([NotNull] Expression expression)
        {
            Check.NotNull(expression, nameof(expression));

            var result = Visit(expression);

            if (result is SqlExpression translation)
            {
                if (translation is SqlUnaryExpression sqlUnaryExpression &&
                    sqlUnaryExpression.OperatorType == ExpressionType.Convert &&
                    sqlUnaryExpression.Type == typeof(object))
                {
                    translation = sqlUnaryExpression.Operand;
                }

                translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

                if ((translation is SqlConstantExpression ||
                     translation is SqlParameterExpression) &&
                    translation.TypeMapping == null)
                {
                    // Non-mappable constant/parameter
                    return(null);
                }

                _sqlTypeMappingVerifyingExpressionVisitor.Visit(translation);

                return(translation);
            }

            return(null);
        }
        public virtual SqlExpression Translate(Expression expression)
        {
            var result = Visit(expression);

            if (result is SqlExpression translation)
            {
                if (translation is SqlUnaryExpression sqlUnaryExpression &&
                    sqlUnaryExpression.OperatorType == ExpressionType.Convert &&
                    sqlUnaryExpression.Type == typeof(object))
                {
                    translation = sqlUnaryExpression.Operand;
                }

                translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

                if (translation is SqlConstantExpression &&
                    translation.TypeMapping == null)
                {
                    // Non-mappable constant
                    return(null);
                }

                _sqlVerifyingExpressionVisitor.Visit(translation);

                return(translation);
            }

            return(null);
        }
        public virtual SqlExpression Translate([NotNull] Expression expression)
        {
            Check.NotNull(expression, nameof(expression));

            var result = Visit(expression);

            if (result is SqlExpression translation)
            {
                if (translation is SqlUnaryExpression sqlUnaryExpression &&
                    sqlUnaryExpression.OperatorType == ExpressionType.Convert &&
                    sqlUnaryExpression.Type == typeof(object))
                {
                    translation = sqlUnaryExpression.Operand;
                }

                translation = SqlExpressionFactory.ApplyDefaultTypeMapping(translation);

                if (translation.TypeMapping == null)
                {
                    // The return type is not-mappable hence return null
                    return(null);
                }

                _sqlTypeMappingVerifyingExpressionVisitor.Visit(translation);

                return(translation);
            }

            return(null);
        }
        public SqlExpression Translate(Expression expression)
        {
            var translation = (SqlExpression)Visit(expression);

            translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

            _sqlVerifyingExpressionVisitor.Visit(translation);

            return(translation);
        }
        public SqlExpression Translate(SelectExpression selectExpression, Expression expression)
        {
            _selectExpression = selectExpression;

            var translation = (SqlExpression)Visit(expression);

            _selectExpression = null;

            translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

            _sqlVerifyingExpressionVisitor.Visit(translation);

            return(translation);
        }
Exemple #6
0
        public SqlExpression Translate(Expression expression)
        {
            var result = Visit(expression);

            if (result is SqlExpression translation)
            {
                translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

                _sqlVerifyingExpressionVisitor.Visit(translation);

                return(translation);
            }

            return(null);
        }
        public SqlExpression Translate(Expression expression)
        {
            var translation = (SqlExpression)Visit(expression);

            if (translation is SqlUnaryExpression sqlUnaryExpression &&
                sqlUnaryExpression.OperatorType == ExpressionType.Convert &&
                sqlUnaryExpression.Type == typeof(object))
            {
                translation = sqlUnaryExpression.Operand;
            }

            translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

            _sqlVerifyingExpressionVisitor.Visit(translation);

            return(translation);
        }
Exemple #8
0
        private SqlExpression TranslateInternal(Expression expression)
        {
            var result = Visit(expression);

            if (result is SqlExpression translation)
            {
                translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

                if (translation.TypeMapping == null)
                {
                    // The return type is not-mappable hence return null
                    return(null);
                }

                _sqlVerifyingExpressionVisitor.Visit(translation);

                return(translation);
            }

            return(null);
        }
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual SqlExpression Translate([NotNull] Expression expression)
        {
            var result = Visit(expression);

            if (result is SqlExpression translation)
            {
                translation = _sqlExpressionFactory.ApplyDefaultTypeMapping(translation);

                if ((translation is SqlConstantExpression ||
                     translation is SqlParameterExpression) &&
                    translation.TypeMapping == null)
                {
                    // Non-mappable constant/parameter
                    return(null);
                }

                _sqlVerifyingExpressionVisitor.Visit(translation);

                return(translation);
            }

            return(null);
        }