Пример #1
0
        /// <summary>
        /// Translates custom methods like <see cref="RelationalQueryableExtensions.AsSubQuery{TEntity}"/>.
        /// </summary>
        /// <param name="visitor">The visitor.</param>
        /// <param name="methodCallExpression">Method call to translate.</param>
        /// <returns>Translated method call if a custom method is found; otherwise <c>null</c>.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="visitor"/> or <paramref name="methodCallExpression"/> is <c>null</c>.
        /// </exception>
        public static ShapedQueryExpression?TranslateCustomMethods(this RelationalQueryableMethodTranslatingExpressionVisitor visitor, MethodCallExpression methodCallExpression)
        {
            if (visitor == null)
            {
                throw new ArgumentNullException(nameof(visitor));
            }
            if (methodCallExpression == null)
            {
                throw new ArgumentNullException(nameof(methodCallExpression));
            }

            if (methodCallExpression.Method.DeclaringType == typeof(RelationalQueryableExtensions) &&
                methodCallExpression.Method.Name == nameof(RelationalQueryableExtensions.AsSubQuery))
            {
                var expression = visitor.Visit(methodCallExpression.Arguments[0]);

                if (expression is ShapedQueryExpression shapedQueryExpression)
                {
                    ((SelectExpression)shapedQueryExpression.QueryExpression).PushdownIntoSubquery();
                    return(shapedQueryExpression);
                }
            }

            return(null);
        }
 public RelationalProjectionBindingExpressionVisitor(
     [NotNull] RelationalQueryableMethodTranslatingExpressionVisitor queryableMethodTranslatingExpressionVisitor,
     [NotNull] RelationalSqlTranslatingExpressionVisitor sqlTranslatingExpressionVisitor)
 {
     _queryableMethodTranslatingExpressionVisitor = queryableMethodTranslatingExpressionVisitor;
     _sqlTranslator = sqlTranslatingExpressionVisitor;
 }
Пример #3
0
 public RelationalProjectionBindingExpressionVisitor(
     [NotNull] RelationalQueryableMethodTranslatingExpressionVisitor queryableMethodTranslatingExpressionVisitor,
     [NotNull] RelationalSqlTranslatingExpressionVisitor sqlTranslatingExpressionVisitor)
 {
     _queryableMethodTranslatingExpressionVisitor = queryableMethodTranslatingExpressionVisitor;
     _sqlTranslator = sqlTranslatingExpressionVisitor;
     _includeFindingExpressionVisitor = new IncludeFindingExpressionVisitor();
     _selectExpression    = null !;
     _existingProjections = Array.Empty <SqlExpression>();
 }
Пример #4
0
 protected ClickHouseQueryableMethodTranslatingExpressionVisitor(RelationalQueryableMethodTranslatingExpressionVisitor parentVisitor)
     : base(parentVisitor)
 {
 }