Exemplo n.º 1
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            var selectExpression = visitor.VisitAndConvert(SelectExpression, nameof(VisitChildren));
            var outerKeySelector = visitor.VisitAndConvert(OuterKeySelector, nameof(VisitChildren));
            var innerKeySelector = visitor.VisitAndConvert(InnerKeySelector, nameof(VisitChildren));
            var innerKeyLambda   = visitor.VisitAndConvert(InnerKeyLambda, nameof(VisitChildren));

            if (selectExpression != SelectExpression)
            {
                var oldTables = SelectExpression.Table.Flatten().ToArray();
                var newTables = selectExpression.Table.Flatten().ToArray();

                var updater = new TableUpdatingExpressionVisitor(oldTables, newTables);

                outerKeySelector = updater.VisitAndConvert(outerKeySelector, nameof(VisitChildren));
                innerKeySelector = updater.VisitAndConvert(innerKeySelector, nameof(VisitChildren));
            }

            if (selectExpression != SelectExpression ||
                outerKeySelector != OuterKeySelector ||
                innerKeySelector != InnerKeySelector ||
                innerKeyLambda != InnerKeyLambda)
            {
                return(new GroupedRelationalQueryExpression(
                           selectExpression,
                           outerKeySelector,
                           innerKeySelector,
                           innerKeyLambda,
                           RequiresDenullification,
                           Type));
            }

            return(this);
        }
Exemplo n.º 2
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            var outerTable = visitor.VisitAndConvert(OuterTable, nameof(VisitChildren));
            var innerTable = visitor.VisitAndConvert(InnerTable, nameof(VisitChildren));
            var predicate  = visitor.Visit(Predicate);

            if (outerTable != OuterTable || innerTable != InnerTable || predicate != Predicate)
            {
                if (outerTable != OuterTable)
                {
                    var oldTables = OuterTable.Flatten().ToArray();
                    var newTables = outerTable.Flatten().ToArray();

                    var updater = new TableUpdatingExpressionVisitor(oldTables, newTables);

                    innerTable = updater.VisitAndConvert(innerTable, nameof(VisitChildren));
                    predicate  = updater.Visit(predicate);
                }

                if (innerTable != InnerTable)
                {
                    var oldTables = InnerTable.Flatten().ToArray();
                    var newTables = innerTable.Flatten().ToArray();

                    var updater = new TableUpdatingExpressionVisitor(oldTables, newTables);

                    predicate = updater.Visit(predicate);
                }

                return(Recreate(outerTable, innerTable, predicate, Type));
            }

            return(this);
        }
Exemplo n.º 3
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            var selectExpression = visitor.VisitAndConvert(SelectExpression, nameof(VisitChildren));
            var outerKeySelector = visitor.VisitAndConvert(OuterKeySelector, nameof(VisitChildren));
            var innerKeySelector = visitor.VisitAndConvert(InnerKeySelector, nameof(VisitChildren));
            var innerKeyLambda   = visitor.VisitAndConvert(InnerKeyLambda, nameof(VisitChildren));
            var elementSelector  = visitor.VisitAndConvert(ElementSelector, nameof(VisitChildren));

            if (selectExpression != SelectExpression)
            {
                var oldTables = SelectExpression.Table.Flatten().ToArray();
                var newTables = selectExpression.Table.Flatten().ToArray();

                var updater = new TableUpdatingExpressionVisitor(oldTables, newTables);

                innerKeySelector = updater.VisitAndConvert(innerKeySelector, nameof(VisitChildren));
                elementSelector  = updater.VisitAndConvert(elementSelector, nameof(VisitChildren));
            }

            if (selectExpression != SelectExpression ||
                outerKeySelector != OuterKeySelector ||
                innerKeySelector != InnerKeySelector ||
                innerKeyLambda != InnerKeyLambda ||
                elementSelector != ElementSelector)
            {
                return(new GroupByResultExpression(
                           selectExpression,
                           outerKeySelector,
                           innerKeySelector,
                           innerKeyLambda,
                           elementSelector,
                           IsDistinct));
            }

            return(this);
        }
Exemplo n.º 4
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            var outerTable = visitor.VisitAndConvert(OuterTable, nameof(VisitChildren));
            var innerTable = visitor.VisitAndConvert(InnerTable, nameof(VisitChildren));

            if (outerTable != OuterTable || innerTable != InnerTable)
            {
                if (outerTable != OuterTable)
                {
                    var oldTables = OuterTable.Flatten().ToArray();
                    var newTables = outerTable.Flatten().ToArray();

                    var updater = new TableUpdatingExpressionVisitor(oldTables, newTables);

                    innerTable = updater.VisitAndConvert(innerTable, nameof(VisitChildren));
                }

                return(new OuterApplyTableExpression(outerTable, innerTable, Type));
            }

            return(this);
        }
Exemplo n.º 5
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            var projection = visitor.VisitAndConvert(Projection, nameof(VisitChildren));
            var table      = visitor.VisitAndConvert(Table, nameof(VisitChildren));
            var predicate  = visitor.VisitAndConvert(Predicate, nameof(VisitChildren));
            var orderBy    = visitor.VisitAndConvert(OrderBy, nameof(VisitChildren));
            var offset     = visitor.VisitAndConvert(Offset, nameof(VisitChildren));
            var limit      = visitor.VisitAndConvert(Limit, nameof(VisitChildren));
            var grouping   = visitor.VisitAndConvert(Grouping, nameof(VisitChildren));

            if (table != Table)
            {
                var oldTables = Table.Flatten().ToArray();
                var newTables = table.Flatten().ToArray();

                var updater = new TableUpdatingExpressionVisitor(oldTables, newTables);

                projection = updater.VisitAndConvert(projection, nameof(VisitChildren));
                predicate  = updater.VisitAndConvert(predicate, nameof(VisitChildren));
                orderBy    = updater.VisitAndConvert(orderBy, nameof(VisitChildren));
                offset     = updater.VisitAndConvert(offset, nameof(VisitChildren));
                limit      = updater.VisitAndConvert(limit, nameof(VisitChildren));
                grouping   = updater.VisitAndConvert(grouping, nameof(VisitChildren));
            }

            if (projection != Projection ||
                table != Table ||
                predicate != Predicate ||
                orderBy != OrderBy ||
                offset != Offset ||
                limit != Limit ||
                grouping != Grouping)
            {
                return(new SelectExpression(projection, table, predicate, orderBy, offset, limit, IsDistinct, grouping, IsWindowed));
            }

            return(this);
        }